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

platform/x86: Enable Atom PMC platform clocks

The BayTrail and CherryTrail platforms provide platform clocks
through their Power Management Controller (PMC).

The SoC supports up to 6 clocks (PMC_PLT_CLK[0..5]) with a
frequency of either 19.2 MHz (PLL) or 25 MHz (XTAL) for BayTrail
and a frequency of 19.2 MHz (XTAL) for CherryTrail. These clocks
are available for general system use, where appropriate. For example,
the usage for platform clocks suggested in the datasheet is the
following:
PLT_CLK[0..2] - Camera
PLT_CLK[3] - Audio Codec
PLT_CLK[4] -
PLT_CLK[5] - COMMs

Signed-off-by: Irina Tirdea <irina.tirdea@intel.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>

authored by

Irina Tirdea and committed by
Stephen Boyd
282a4e4c 80a7581f

+77 -3
+1
drivers/platform/x86/Kconfig
··· 1081 1081 config PMC_ATOM 1082 1082 def_bool y 1083 1083 depends on PCI 1084 + select COMMON_CLK
+76 -3
drivers/platform/x86/pmc_atom.c
··· 19 19 #include <linux/device.h> 20 20 #include <linux/init.h> 21 21 #include <linux/io.h> 22 + #include <linux/platform_data/x86/clk-pmc-atom.h> 22 23 #include <linux/platform_data/x86/pmc_atom.h> 24 + #include <linux/platform_device.h> 23 25 #include <linux/pci.h> 24 26 #include <linux/seq_file.h> 25 27 ··· 38 36 const struct pmc_bit_map *pss; 39 37 }; 40 38 39 + struct pmc_data { 40 + const struct pmc_reg_map *map; 41 + const struct pmc_clk *clks; 42 + }; 43 + 41 44 struct pmc_dev { 42 45 u32 base_addr; 43 46 void __iomem *regmap; ··· 55 48 56 49 static struct pmc_dev pmc_device; 57 50 static u32 acpi_base_addr; 51 + 52 + static const struct pmc_clk byt_clks[] = { 53 + { 54 + .name = "xtal", 55 + .freq = 25000000, 56 + .parent_name = NULL, 57 + }, 58 + { 59 + .name = "pll", 60 + .freq = 19200000, 61 + .parent_name = "xtal", 62 + }, 63 + {}, 64 + }; 65 + 66 + static const struct pmc_clk cht_clks[] = { 67 + { 68 + .name = "xtal", 69 + .freq = 19200000, 70 + .parent_name = NULL, 71 + }, 72 + {}, 73 + }; 58 74 59 75 static const struct pmc_bit_map d3_sts_0_map[] = { 60 76 {"LPSS1_F0_DMA", BIT_LPSS1_F0_DMA}, ··· 196 166 .func_dis = d3_sts_0_map, 197 167 .func_dis_2 = cht_func_dis_2_map, 198 168 .pss = cht_pss_map, 169 + }; 170 + 171 + static const struct pmc_data byt_data = { 172 + .map = &byt_reg_map, 173 + .clks = byt_clks, 174 + }; 175 + 176 + static const struct pmc_data cht_data = { 177 + .map = &cht_reg_map, 178 + .clks = cht_clks, 199 179 }; 200 180 201 181 static inline u32 pmc_reg_read(struct pmc_dev *pmc, int reg_offset) ··· 421 381 } 422 382 #endif /* CONFIG_DEBUG_FS */ 423 383 384 + static int pmc_setup_clks(struct pci_dev *pdev, void __iomem *pmc_regmap, 385 + const struct pmc_data *pmc_data) 386 + { 387 + struct platform_device *clkdev; 388 + struct pmc_clk_data *clk_data; 389 + 390 + clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); 391 + if (!clk_data) 392 + return -ENOMEM; 393 + 394 + clk_data->base = pmc_regmap; /* offset is added by client */ 395 + clk_data->clks = pmc_data->clks; 396 + 397 + clkdev = platform_device_register_data(&pdev->dev, "clk-pmc-atom", 398 + PLATFORM_DEVID_NONE, 399 + clk_data, sizeof(*clk_data)); 400 + if (IS_ERR(clkdev)) { 401 + kfree(clk_data); 402 + return PTR_ERR(clkdev); 403 + } 404 + 405 + kfree(clk_data); 406 + 407 + return 0; 408 + } 409 + 424 410 static int pmc_setup_dev(struct pci_dev *pdev, const struct pci_device_id *ent) 425 411 { 426 412 struct pmc_dev *pmc = &pmc_device; 427 - const struct pmc_reg_map *map = (struct pmc_reg_map *)ent->driver_data; 413 + const struct pmc_data *data = (struct pmc_data *)ent->driver_data; 414 + const struct pmc_reg_map *map = data->map; 428 415 int ret; 429 416 430 417 /* Obtain ACPI base address */ ··· 480 413 if (ret) 481 414 dev_warn(&pdev->dev, "debugfs register failed\n"); 482 415 416 + /* Register platform clocks - PMC_PLT_CLK [0..5] */ 417 + ret = pmc_setup_clks(pdev, pmc->regmap, data); 418 + if (ret) 419 + dev_warn(&pdev->dev, "platform clocks register failed: %d\n", 420 + ret); 421 + 483 422 pmc->init = true; 484 423 return ret; 485 424 } ··· 496 423 * used by pci_match_id() call below. 497 424 */ 498 425 static const struct pci_device_id pmc_pci_ids[] = { 499 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_VLV_PMC), (kernel_ulong_t)&byt_reg_map }, 500 - { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_CHT_PMC), (kernel_ulong_t)&cht_reg_map }, 426 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_VLV_PMC), (kernel_ulong_t)&byt_data }, 427 + { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_CHT_PMC), (kernel_ulong_t)&cht_data }, 501 428 { 0, }, 502 429 }; 503 430