Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: cdce925: add support for CDCE913, CDCE937, and CDCE949

The CDCE925 is a member of the CDCE(L)9xx programmable clock generator
family. There are also CDCE913, CDCE937, CDCE949 which have different
number of PLLs and outputs.

The clk-cdce925 driver supports only CDCE925 in the family. This adds
support for the CDCE913, CDCE937, CDCE949, too.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Rob Herring <robh@kernel.org>
Cc: Mike Looijmans <mike.looijmans@topic.nl>
Cc: Michael Turquette <mturquette@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Akinobu Mita and committed by
Stephen Boyd
5508124c 8e18d065

+100 -34
+11 -4
Documentation/devicetree/bindings/clock/ti,cdce925.txt
··· 1 - Binding for TO CDCE925 programmable I2C clock synthesizers. 1 + Binding for TI CDCE913/925/937/949 programmable I2C clock synthesizers. 2 2 3 3 Reference 4 4 This binding uses the common clock binding[1]. 5 5 6 6 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt 7 - [2] http://www.ti.com/product/cdce925 7 + [2] http://www.ti.com/product/cdce913 8 + [3] http://www.ti.com/product/cdce925 9 + [4] http://www.ti.com/product/cdce937 10 + [5] http://www.ti.com/product/cdce949 8 11 9 12 The driver provides clock sources for each output Y1 through Y5. 10 13 11 14 Required properties: 12 - - compatible: Shall be "ti,cdce925" 15 + - compatible: Shall be one of the following: 16 + - "ti,cdce913": 1-PLL, 3 Outputs 17 + - "ti,cdce925": 2-PLL, 5 Outputs 18 + - "ti,cdce937": 3-PLL, 7 Outputs 19 + - "ti,cdce949": 4-PLL, 9 Outputs 13 20 - reg: I2C device address. 14 21 - clocks: Points to a fixed parent clock that provides the input frequency. 15 22 - #clock-cells: From common clock bindings: Shall be 1. ··· 25 18 - xtal-load-pf: Crystal load-capacitor value to fine-tune performance on a 26 19 board, or to compensate for external influences. 27 20 28 - For both PLL1 and PLL2 an optional child node can be used to specify spread 21 + For all PLL1, PLL2, ... an optional child node can be used to specify spread 29 22 spectrum clocking parameters for a board. 30 23 - spread-spectrum: SSC mode as defined in the data sheet. 31 24 - spread-spectrum-center: Use "centered" mode instead of "max" mode. When
+6 -5
drivers/clk/Kconfig
··· 95 95 This driver supports TI CDCE706 programmable 3-PLL clock synthesizer. 96 96 97 97 config COMMON_CLK_CDCE925 98 - tristate "Clock driver for TI CDCE925 devices" 98 + tristate "Clock driver for TI CDCE913/925/937/949 devices" 99 99 depends on I2C 100 100 depends on OF 101 101 select REGMAP_I2C 102 102 help 103 103 ---help--- 104 - This driver supports the TI CDCE925 programmable clock synthesizer. 105 - The chip contains two PLLs with spread-spectrum clocking support and 106 - five output dividers. The driver only supports the following setup, 107 - and uses a fixed setting for the output muxes. 104 + This driver supports the TI CDCE913/925/937/949 programmable clock 105 + synthesizer. Each chip has different number of PLLs and outputs. 106 + For example, the CDCE925 contains two PLLs with spread-spectrum 107 + clocking support and five output dividers. The driver only supports 108 + the following setup, and uses a fixed setting for the output muxes. 108 109 Y1 is derived from the input clock 109 110 Y2 and Y3 derive from PLL1 110 111 Y4 and Y5 derive from PLL2
+83 -25
drivers/clk/clk-cdce925.c
··· 1 1 /* 2 - * Driver for TI Dual PLL CDCE925 clock synthesizer 2 + * Driver for TI Multi PLL CDCE913/925/937/949 clock synthesizer 3 3 * 4 - * This driver always connects the Y1 to the input clock, Y2/Y3 to PLL1 5 - * and Y4/Y5 to PLL2. PLL frequency is set on a first-come-first-serve 4 + * This driver always connects the Y1 to the input clock, Y2/Y3 to PLL1, 5 + * Y4/Y5 to PLL2, and so on. PLL frequency is set on a first-come-first-serve 6 6 * basis. Clients can directly request any frequency that the chip can 7 7 * deliver using the standard clk framework. In addition, the device can 8 8 * be configured and activated via the devicetree. ··· 19 19 #include <linux/slab.h> 20 20 #include <linux/gcd.h> 21 21 22 - /* The chip has 2 PLLs which can be routed through dividers to 5 outputs. 22 + /* Each chip has different number of PLLs and outputs, for example: 23 + * The CECE925 has 2 PLLs which can be routed through dividers to 5 outputs. 23 24 * Model this as 2 PLL clocks which are parents to the outputs. 24 25 */ 25 - #define NUMBER_OF_PLLS 2 26 - #define NUMBER_OF_OUTPUTS 5 26 + 27 + enum { 28 + CDCE913, 29 + CDCE925, 30 + CDCE937, 31 + CDCE949, 32 + }; 33 + 34 + struct clk_cdce925_chip_info { 35 + int num_plls; 36 + int num_outputs; 37 + }; 38 + 39 + static const struct clk_cdce925_chip_info clk_cdce925_chip_info_tbl[] = { 40 + [CDCE913] = { .num_plls = 1, .num_outputs = 3 }, 41 + [CDCE925] = { .num_plls = 2, .num_outputs = 5 }, 42 + [CDCE937] = { .num_plls = 3, .num_outputs = 7 }, 43 + [CDCE949] = { .num_plls = 4, .num_outputs = 9 }, 44 + }; 45 + 46 + #define MAX_NUMBER_OF_PLLS 4 47 + #define MAX_NUMBER_OF_OUTPUTS 9 27 48 28 49 #define CDCE925_REG_GLOBAL1 0x01 29 50 #define CDCE925_REG_Y1SPIPDIVH 0x02 ··· 64 43 struct clk_hw hw; 65 44 struct clk_cdce925_chip *chip; 66 45 u8 index; 67 - u16 pdiv; /* 1..127 for Y2-Y5; 1..1023 for Y1 */ 46 + u16 pdiv; /* 1..127 for Y2-Y9; 1..1023 for Y1 */ 68 47 }; 69 48 #define to_clk_cdce925_output(_hw) \ 70 49 container_of(_hw, struct clk_cdce925_output, hw) ··· 81 60 struct clk_cdce925_chip { 82 61 struct regmap *regmap; 83 62 struct i2c_client *i2c_client; 84 - struct clk_cdce925_pll pll[NUMBER_OF_PLLS]; 85 - struct clk_cdce925_output clk[NUMBER_OF_OUTPUTS]; 63 + const struct clk_cdce925_chip_info *chip_info; 64 + struct clk_cdce925_pll pll[MAX_NUMBER_OF_PLLS]; 65 + struct clk_cdce925_output clk[MAX_NUMBER_OF_OUTPUTS]; 86 66 }; 87 67 88 68 /* ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** */ ··· 306 284 case 4: 307 285 regmap_update_bits(data->chip->regmap, 0x27, 0x7F, pdiv); 308 286 break; 287 + case 5: 288 + regmap_update_bits(data->chip->regmap, 0x36, 0x7F, pdiv); 289 + break; 290 + case 6: 291 + regmap_update_bits(data->chip->regmap, 0x37, 0x7F, pdiv); 292 + break; 293 + case 7: 294 + regmap_update_bits(data->chip->regmap, 0x46, 0x7F, pdiv); 295 + break; 296 + case 8: 297 + regmap_update_bits(data->chip->regmap, 0x47, 0x7F, pdiv); 298 + break; 309 299 } 310 300 } 311 301 ··· 335 301 case 3: 336 302 case 4: 337 303 regmap_update_bits(data->chip->regmap, 0x24, 0x03, 0x03); 304 + break; 305 + case 5: 306 + case 6: 307 + regmap_update_bits(data->chip->regmap, 0x34, 0x03, 0x03); 308 + break; 309 + case 7: 310 + case 8: 311 + regmap_update_bits(data->chip->regmap, 0x44, 0x03, 0x03); 338 312 break; 339 313 } 340 314 } ··· 516 474 .set_rate = cdce925_clk_y1_set_rate, 517 475 }; 518 476 519 - 520 - static struct regmap_config cdce925_regmap_config = { 521 - .name = "configuration0", 522 - .reg_bits = 8, 523 - .val_bits = 8, 524 - .cache_type = REGCACHE_RBTREE, 525 - .max_register = 0x2F, 526 - }; 527 - 528 477 #define CDCE925_I2C_COMMAND_BLOCK_TRANSFER 0x00 529 478 #define CDCE925_I2C_COMMAND_BYTE_TRANSFER 0x80 530 479 ··· 615 582 struct clk_cdce925_chip *data; 616 583 struct device_node *node = client->dev.of_node; 617 584 const char *parent_name; 618 - const char *pll_clk_name[NUMBER_OF_PLLS] = {NULL,}; 585 + const char *pll_clk_name[MAX_NUMBER_OF_PLLS] = {NULL,}; 619 586 struct clk_init_data init; 620 587 u32 value; 621 588 int i; 622 589 int err; 623 590 struct device_node *np_output; 624 591 char child_name[6]; 592 + struct regmap_config config = { 593 + .name = "configuration0", 594 + .reg_bits = 8, 595 + .val_bits = 8, 596 + .cache_type = REGCACHE_RBTREE, 597 + }; 625 598 626 599 dev_dbg(&client->dev, "%s\n", __func__); 627 600 data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); ··· 635 596 return -ENOMEM; 636 597 637 598 data->i2c_client = client; 599 + data->chip_info = &clk_cdce925_chip_info_tbl[id->driver_data]; 600 + config.max_register = CDCE925_OFFSET_PLL + 601 + data->chip_info->num_plls * 0x10 - 1; 638 602 data->regmap = devm_regmap_init(&client->dev, &regmap_cdce925_bus, 639 - &client->dev, &cdce925_regmap_config); 603 + &client->dev, &config); 640 604 if (IS_ERR(data->regmap)) { 641 605 dev_err(&client->dev, "failed to allocate register map\n"); 642 606 return PTR_ERR(data->regmap); ··· 668 626 init.num_parents = parent_name ? 1 : 0; 669 627 670 628 /* Register PLL clocks */ 671 - for (i = 0; i < NUMBER_OF_PLLS; ++i) { 629 + for (i = 0; i < data->chip_info->num_plls; ++i) { 672 630 pll_clk_name[i] = kasprintf(GFP_KERNEL, "%s.pll%d", 673 631 client->dev.of_node->name, i); 674 632 init.name = pll_clk_name[i]; ··· 726 684 init.ops = &cdce925_clk_ops; 727 685 init.flags = CLK_SET_RATE_PARENT; 728 686 init.num_parents = 1; 729 - for (i = 1; i < NUMBER_OF_OUTPUTS; ++i) { 687 + for (i = 1; i < data->chip_info->num_outputs; ++i) { 730 688 init.name = kasprintf(GFP_KERNEL, "%s.Y%d", 731 689 client->dev.of_node->name, i+1); 732 690 data->clk[i].chip = data; ··· 743 701 case 4: 744 702 /* Mux Y4/5 to PLL2 */ 745 703 init.parent_names = &pll_clk_name[1]; 704 + break; 705 + case 5: 706 + case 6: 707 + /* Mux Y6/7 to PLL3 */ 708 + init.parent_names = &pll_clk_name[2]; 709 + break; 710 + case 7: 711 + case 8: 712 + /* Mux Y8/9 to PLL4 */ 713 + init.parent_names = &pll_clk_name[3]; 746 714 break; 747 715 } 748 716 err = devm_clk_hw_register(&client->dev, &data->clk[i].hw); ··· 772 720 err = 0; 773 721 774 722 error: 775 - for (i = 0; i < NUMBER_OF_PLLS; ++i) 723 + for (i = 0; i < data->chip_info->num_plls; ++i) 776 724 /* clock framework made a copy of the name */ 777 725 kfree(pll_clk_name[i]); 778 726 ··· 780 728 } 781 729 782 730 static const struct i2c_device_id cdce925_id[] = { 783 - { "cdce925", 0 }, 731 + { "cdce913", CDCE913 }, 732 + { "cdce925", CDCE925 }, 733 + { "cdce937", CDCE937 }, 734 + { "cdce949", CDCE949 }, 784 735 { } 785 736 }; 786 737 MODULE_DEVICE_TABLE(i2c, cdce925_id); 787 738 788 739 static const struct of_device_id clk_cdce925_of_match[] = { 740 + { .compatible = "ti,cdce913" }, 789 741 { .compatible = "ti,cdce925" }, 742 + { .compatible = "ti,cdce937" }, 743 + { .compatible = "ti,cdce949" }, 790 744 { }, 791 745 }; 792 746 MODULE_DEVICE_TABLE(of, clk_cdce925_of_match); ··· 808 750 module_i2c_driver(cdce925_driver); 809 751 810 752 MODULE_AUTHOR("Mike Looijmans <mike.looijmans@topic.nl>"); 811 - MODULE_DESCRIPTION("cdce925 driver"); 753 + MODULE_DESCRIPTION("TI CDCE913/925/937/949 driver"); 812 754 MODULE_LICENSE("GPL");