static void clkdev_add_pci(void) { struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL); /* main pci clock */ clk->cl.dev_id = "17000000.pci"; clk->cl.con_id = NULL; clk->cl.clk = clk; clk->rate = CLOCK_33M; clk->rates = valid_pci_rates; clk->enable = pci_enable; clk->disable = pmu_disable; clk->module = 0; clk->bits = PMU_PCI; clkdev_add(&clk->cl); /* use internal/external bus clock */ clk_ext->cl.dev_id = "17000000.pci"; clk_ext->cl.con_id = "external"; clk_ext->cl.clk = clk_ext; clk_ext->enable = pci_ext_enable; clk_ext->disable = pci_ext_disable; clkdev_add(&clk_ext->cl); }
int __init am33xx_clk_init(void) { struct omap_clk *c; u32 cpu_clkflg; if (soc_is_am33xx()) { cpu_mask = RATE_IN_AM33XX; cpu_clkflg = CK_AM33XX; } clk_init(&omap2_clk_functions); for (c = am33xx_clks; c < am33xx_clks + ARRAY_SIZE(am33xx_clks); c++) clk_preinit(c->lk.clk); for (c = am33xx_clks; c < am33xx_clks + ARRAY_SIZE(am33xx_clks); c++) { if (c->cpu & cpu_clkflg) { clkdev_add(&c->lk); clk_register(c->lk.clk); omap2_init_clk_clkdm(c->lk.clk); } } recalculate_root_clocks(); /* * Only enable those clocks we will need, let the drivers * enable other clocks as necessary */ clk_enable_init_clocks(); return 0; }
void clks_register(struct clk_lookup *clks, size_t num) { unsigned int i; for (i = 0; i < num; i++) clkdev_add(&clks[i]); }
static void _add_clkdev(struct omap_device *od, const char *clk_alias, const char *clk_name) { struct clk *r; struct clk_lookup *l; if (!clk_alias || !clk_name) return; dev_dbg(&od->pdev->dev, "Creating %s -> %s\n", clk_alias, clk_name); r = clk_get_sys(dev_name(&od->pdev->dev), clk_alias); if (!IS_ERR(r)) { dev_dbg(&od->pdev->dev, "alias %s already exists\n", clk_alias); clk_put(r); return; } r = clk_get(NULL, clk_name); if (IS_ERR(r)) { dev_err(&od->pdev->dev, "clk_get for %s failed\n", clk_name); return; } l = clkdev_alloc(r, clk_alias, dev_name(&od->pdev->dev)); if (!l) { dev_err(&od->pdev->dev, "clkdev_alloc for %s failed\n", clk_alias); return; } clkdev_add(l); }
static int __init omap_hsi_init(void) { int err; struct clk *hsi_clk = &hsi_clock.clk; hsi_clk_init(&hsi_clock); clk_preinit(hsi_clk); #ifdef OMAP_HSI_EXAMPLE_PWR_CODE clkdev_add(&hsi_lk); #endif clk_register(hsi_clk); #ifdef OMAP_HSI_EXAMPLE_PWR_CODE omap2_init_clk_clkdm(hsi_clk); #endif err = platform_device_register(&hsi_pdev); if (err < 0) { pr_err("Unable to register HSI platform device: %d\n", err); return err; } omap_hsi_mux_setup(); pr_info("HSI: device registered\n"); return 0; }
void __init tegra30_init_clocks(void) { int i; struct clk *c; for (i = 0; i < ARRAY_SIZE(tegra_ptr_clks); i++) tegra30_init_one_clock(tegra_ptr_clks[i]); for (i = 0; i < ARRAY_SIZE(tegra_list_clks); i++) tegra30_init_one_clock(tegra_list_clks[i]); for (i = 0; i < ARRAY_SIZE(tegra_clk_duplicates); i++) { c = tegra_get_clock_by_name(tegra_clk_duplicates[i].name); if (!c) { pr_err("%s: Unknown duplicate clock %s\n", __func__, tegra_clk_duplicates[i].name); continue; } tegra_clk_duplicates[i].lookup.clk = c; clkdev_add(&tegra_clk_duplicates[i].lookup); } for (i = 0; i < ARRAY_SIZE(tegra_sync_source_list); i++) tegra30_init_one_clock(tegra_sync_source_list[i]); for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_list); i++) tegra30_init_one_clock(tegra_clk_audio_list[i]); for (i = 0; i < ARRAY_SIZE(tegra_clk_audio_2x_list); i++) tegra30_init_one_clock(tegra_clk_audio_2x_list[i]); for (i = 0; i < ARRAY_SIZE(tegra_clk_out_list); i++) tegra30_init_one_clock(tegra_clk_out_list[i]); tegra30_cpu_car_ops_init(); }
/** * _add_optional_clock_clkdev - Add clkdev entry for hwmod optional clocks * @od: struct omap_device *od * * For every optional clock present per hwmod per omap_device, this function * adds an entry in the clkdev table of the form <dev-id=dev_name, con-id=role> * if it does not exist already. * * The function is called from inside omap_device_build_ss(), after * omap_device_register. * * This allows drivers to get a pointer to its optional clocks based on its role * by calling clk_get(<dev*>, <role>). * * No return value. */ static void _add_optional_clock_clkdev(struct omap_device *od, struct omap_hwmod *oh) { int i; for (i = 0; i < oh->opt_clks_cnt; i++) { struct omap_hwmod_opt_clk *oc; struct clk *r; struct clk_lookup *l; oc = &oh->opt_clks[i]; if (!oc->_clk) continue; r = clk_get_sys(dev_name(&od->pdev.dev), oc->role); if (!IS_ERR(r)) continue; /* clkdev entry exists */ r = omap_clk_get_by_name((char *)oc->clk); if (IS_ERR(r)) { pr_err("omap_device: %s: omap_clk_get_by_name for %s failed\n", dev_name(&od->pdev.dev), oc->clk); continue; } l = clkdev_alloc(r, oc->role, dev_name(&od->pdev.dev)); if (!l) { pr_err("omap_device: %s: clkdev_alloc for %s failed\n", dev_name(&od->pdev.dev), oc->role); return; } clkdev_add(l); } }
void __init bcm2708_init(void) { int i; printk("bcm2708.uart_clock = %d\n", uart_clock); pm_power_off = bcm2708_power_off; if (uart_clock) lookups[0].clk->rate = uart_clock; for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); bcm_register_device(&bcm2708_dmaman_device); bcm_register_device(&bcm2708_vcio_device); #ifdef CONFIG_BCM2708_GPIO bcm_register_device(&bcm2708_gpio_device); #endif #if defined(CONFIG_W1_MASTER_GPIO) || defined(CONFIG_W1_MASTER_GPIO_MODULE) platform_device_register(&w1_device); #endif bcm_register_device(&bcm2708_systemtimer_device); #ifdef CONFIG_MMC_BCM2708 bcm_register_device(&bcm2708_mci_device); #endif bcm_register_device(&bcm2708_fb_device); if (!fiq_fix_enable) { bcm2708_usb_device.resource = bcm2708_usb_resources_no_fiq_fix; bcm2708_usb_device.num_resources = ARRAY_SIZE(bcm2708_usb_resources_no_fiq_fix); } bcm_register_device(&bcm2708_usb_device); bcm_register_device(&bcm2708_uart1_device); bcm_register_device(&bcm2708_powerman_device); #ifdef CONFIG_MMC_SDHCI_BCM2708 bcm_register_device(&bcm2708_emmc_device); #endif bcm2708_init_led(); for (i = 0; i < ARRAY_SIZE(bcm2708_alsa_devices); i++) bcm_register_device(&bcm2708_alsa_devices[i]); bcm_register_device(&bcm2708_spi_device); bcm_register_device(&bcm2708_bsc0_device); bcm_register_device(&bcm2708_bsc1_device); bcm_register_device(&bcm2835_hwmon_device); bcm_register_device(&bcm2835_thermal_device); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); } system_rev = boardrev; system_serial_low = serial; #ifdef CONFIG_SPI spi_register_board_info(bcm2708_spi_devices, ARRAY_SIZE(bcm2708_spi_devices)); #endif }
static int sdk7786_clk_init(void) { struct clk *clk; int ret; /* * Only handle the EXTAL case, anyone interfacing a crystal * resonator will need to provide their own input clock. */ if (test_mode_pin(MODE_PIN9)) return -EINVAL; clk = clk_get(NULL, "extal"); if (IS_ERR(clk)) return PTR_ERR(clk); ret = clk_set_rate(clk, 33333333); clk_put(clk); /* * Setup the FPGA clocks. */ ret = clk_register(&sdk7786_pcie_clk); if (unlikely(ret)) { pr_err("FPGA clock registration failed\n"); return ret; } clkdev_add(&sdk7786_pcie_cl); return 0; }
static int __init clk_init(void) { int i; for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); return 0; }
static void __init clk_register(void) { int i; for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); }
int __init omap2_clk_init(void) { struct prcm_config *prcm; struct omap_clk *c; u32 clkrate; if (cpu_is_omap242x()) cpu_mask = RATE_IN_242X; else if (cpu_is_omap2430()) cpu_mask = RATE_IN_243X; clk_init(&omap2_clk_functions); for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++) clk_init_one(c->lk.clk); osc_ck.rate = omap2_osc_clk_recalc(&osc_ck); propagate_rate(&osc_ck); sys_ck.rate = omap2_sys_clk_recalc(&sys_ck); propagate_rate(&sys_ck); for (c = omap24xx_clks; c < omap24xx_clks + ARRAY_SIZE(omap24xx_clks); c++) if (c->cpu & cpu_mask) { clkdev_add(&c->lk); clk_register(c->lk.clk); } /* Check the MPU rate set by bootloader */ clkrate = omap2xxx_clk_get_core_rate(&dpll_ck); for (prcm = rate_table; prcm->mpu_speed; prcm++) { if (!(prcm->flags & cpu_mask)) continue; if (prcm->xtal_speed != sys_ck.rate) continue; if (prcm->dpll_speed <= clkrate) break; } curr_prcm_set = prcm; recalculate_root_clocks(); printk(KERN_INFO "Clocking rate (Crystal/DPLL/MPU): " "%ld.%01ld/%ld/%ld MHz\n", (sys_ck.rate / 1000000), (sys_ck.rate / 100000) % 10, (dpll_ck.rate / 1000000), (mpu_ck.rate / 1000000)) ; /* * Only enable those clocks we will need, let the drivers * enable other clocks as necessary */ clk_enable_init_clocks(); /* Avoid sleeping sleeping during omap2_clk_prepare_for_reboot() */ vclk = clk_get(NULL, "virt_prcm_set"); sclk = clk_get(NULL, "sys_ck"); return 0; }
void __init tm4c_clock_init(void) { int i; stellaris_clock_init(); for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); }
void __init at91sam9263_set_console_clock(int id) { if (id >= ARRAY_SIZE(usart_clocks_lookups)) return; console_clock_lookup.con_id = "usart"; console_clock_lookup.clk = usart_clocks_lookups[id].clk; clkdev_add(&console_clock_lookup); }
/* Create a clkdev entry for a given device/clk */ void __init orion_clkdev_add(const char *con_id, const char *dev_id, struct clk *clk) { struct clk_lookup *cl; cl = clkdev_alloc(clk, con_id, dev_id); if (cl) clkdev_add(cl); }
/** * omap_clocks_register - register an array of omap_clk * @ocs: pointer to an array of omap_clk to register */ void __init omap_clocks_register(struct omap_clk oclks[], int cnt) { struct omap_clk *c; for (c = oclks; c < oclks + cnt; c++) { clkdev_add(&c->lk); if (!__clk_init(NULL, c->lk.clk)) omap2_init_clk_hw_omap_clocks(c->lk.clk); } }
/* Create a clock structure with the given name */ int nmdk_clk_create(struct clk *clk, const char *dev_id) { struct clk_lookup *clkdev; clkdev = clkdev_alloc(clk, NULL, dev_id); if (!clkdev) return -ENOMEM; clkdev_add(clkdev); return 0; }
static void tegra30_init_one_clock(struct clk *c) { struct clk_tegra *clk = to_clk_tegra(c->hw); __clk_init(NULL, c); INIT_LIST_HEAD(&clk->shared_bus_list); if (!clk->lookup.dev_id && !clk->lookup.con_id) clk->lookup.con_id = c->name; clk->lookup.clk = c; clkdev_add(&clk->lookup); tegra_clk_add(c); }
void __init tegra_init_dup_clks(struct tegra_clk_duplicate *dup_list, struct clk *clks[], int clk_max) { struct clk *clk; for (; dup_list->clk_id < clk_max; dup_list++) { clk = clks[dup_list->clk_id]; dup_list->lookup.clk = clk; clkdev_add(&dup_list->lookup); } }
int __init mx31_clocks_init(unsigned long fref) { u32 reg; int i; ckih_rate = fref; for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); /* change the csi_clk parent if necessary */ reg = __raw_readl(MXC_CCM_CCMR); if (!(reg & MXC_CCM_CCMR_CSCS)) if (clk_set_parent(&csi_clk, &usb_pll_clk)) pr_err("%s: error changing csi_clk parent\n", __func__); /* Turn off all possible clocks */ __raw_writel((3 << 4), MXC_CCM_CGR0); __raw_writel(0, MXC_CCM_CGR1); __raw_writel((3 << 8) | (3 << 14) | (3 << 16)| 1 << 27 | 1 << 28, /* Bit 27 and 28 are not defined for MX32, but still required to be set */ MXC_CCM_CGR2); /* * Before turning off usb_pll make sure ipg_per_clk is generated * by ipg_clk and not usb_pll. */ __raw_writel(__raw_readl(MXC_CCM_CCMR) | (1 << 24), MXC_CCM_CCMR); usb_pll_disable(&usb_pll_clk); pr_info("Clock input source is %ld\n", clk_get_rate(&ckih_clk)); clk_enable(&gpt_clk); clk_enable(&emi_clk); clk_enable(&iim_clk); clk_enable(&serial_pll_clk); if (mx31_revision() >= CHIP_REV_2_0) { reg = __raw_readl(MXC_CCM_PMCR1); /* No PLL restart on DVFS switch; enable auto EMI handshake */ reg |= MXC_CCM_PMCR1_PLLRDIS | MXC_CCM_PMCR1_EMIRQ_EN; __raw_writel(reg, MXC_CCM_PMCR1); } mxc_timer_init(&ipg_clk, IO_ADDRESS(GPT1_BASE_ADDR), MXC_INT_GPT); return 0; }
/** * ak39xx_register_clock() - register a clock * @clk: The clock to register * * Add the specified clock to the list of clocks known by the system. */ int ak39xx_register_clock(struct clk *clk) { if (clk->enable == NULL) clk->enable = clk_null_enable; /* fill up the clk_lookup structure and register it*/ clk->lookup.dev_id = clk->devname; clk->lookup.con_id = clk->name; clk->lookup.clk = clk; clkdev_add(&clk->lookup); return 0; }
/* manage the clock generator */ static void clkdev_add_cgu(const char *dev, const char *con, unsigned int bits) { struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); clk->cl.dev_id = dev; clk->cl.con_id = con; clk->cl.clk = clk; clk->enable = cgu_enable; clk->disable = cgu_disable; clk->bits = bits; clkdev_add(&clk->cl); }
void ralink_clk_add(const char *dev, unsigned long rate) { struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); if (!clk) panic("failed to add clock"); clk->cl.dev_id = dev; clk->cl.clk = clk; clk->rate = rate; clkdev_add(&clk->cl); }
static void __init intcp_init(void) { int i; for (i = 0; i < ARRAY_SIZE(cp_lookups); i++) clkdev_add(&cp_lookups[i]); platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs)); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); } }
static int __init integrator_init(void) { int i; for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); } return 0; }
/** * cg2900_core_probe() - Initialize resources. * * Function initializes pf_data structure and also adds the cg2900 * clock source. */ static int __devinit cg2900_core_probe(struct platform_device *pdev) { cg2900_clk_lookup = clkdev_alloc(&cg2900_clk, "sys_clk_out", "cw1200_wlan"); if (!cg2900_clk_lookup) return -ENOMEM; clkdev_add(cg2900_clk_lookup); pf_data = dev_get_platdata(&pdev->dev); pf_data->dev = &pdev->dev; pf_data->read_cb = cg2900_read_cb; return 0; }
static inline void clkdev_add_sys(const char *dev, unsigned int module, unsigned int bits) { struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL); clk->cl.dev_id = dev; clk->cl.con_id = NULL; clk->cl.clk = clk; clk->module = module; clk->bits = bits; clk->activate = sysctl_activate; clk->deactivate = sysctl_deactivate; clk->enable = sysctl_clken; clk->disable = sysctl_clkdis; clk->reboot = sysctl_reboot; clkdev_add(&clk->cl); }
int __init arch_clk_init(void) { int i, ret = 0; for (i = 0; i < ARRAY_SIZE(clks); i++) ret |= clk_register(clks[i]); for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); if (!ret) ret = sh_clk_div4_register(div4_clks, ARRAY_SIZE(div4_clks), &div4_table); if (!ret) ret = sh_clk_mstp32_register(mstp_clks, MSTP_NR); return ret; }
void __init bcmring_amba_init(void) { int i; u32 bus_clock; /* Linux is run initially in non-secure mode. Secure peripherals */ /* generate FIQ, and must be handled in secure mode. Until we have */ /* a linux security monitor implementation, keep everything in */ /* non-secure mode. */ chipcHw_busInterfaceClockEnable(chipcHw_REG_BUS_CLOCK_SPU); secHw_setUnsecure(secHw_BLK_MASK_CHIP_CONTROL | secHw_BLK_MASK_KEY_SCAN | secHw_BLK_MASK_TOUCH_SCREEN | secHw_BLK_MASK_UART0 | secHw_BLK_MASK_UART1 | secHw_BLK_MASK_WATCHDOG | secHw_BLK_MASK_SPUM | secHw_BLK_MASK_DDR2 | secHw_BLK_MASK_SPU | secHw_BLK_MASK_PKA | secHw_BLK_MASK_RNG | secHw_BLK_MASK_RTC | secHw_BLK_MASK_OTP | secHw_BLK_MASK_BOOT | secHw_BLK_MASK_MPU | secHw_BLK_MASK_TZCTRL | secHw_BLK_MASK_INTR); /* Only the devices attached to the AMBA bus are enabled just before the bus is */ /* scanned and the drivers are loaded. The clocks need to be on for the AMBA bus */ /* driver to access these blocks. The bus is probed, and the drivers are loaded. */ /* FIXME Need to remove enable of PIF once CLCD clock enable used properly in FPGA. */ bus_clock = chipcHw_REG_BUS_CLOCK_GE | chipcHw_REG_BUS_CLOCK_SDIO0 | chipcHw_REG_BUS_CLOCK_SDIO1; chipcHw_busInterfaceClockEnable(bus_clock); for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); } }
void __init bcmring_amba_init(void) { int i; u32 bus_clock; chipcHw_busInterfaceClockEnable(chipcHw_REG_BUS_CLOCK_SPU); secHw_setUnsecure(secHw_BLK_MASK_CHIP_CONTROL | secHw_BLK_MASK_KEY_SCAN | secHw_BLK_MASK_TOUCH_SCREEN | secHw_BLK_MASK_UART0 | secHw_BLK_MASK_UART1 | secHw_BLK_MASK_WATCHDOG | secHw_BLK_MASK_SPUM | secHw_BLK_MASK_DDR2 | secHw_BLK_MASK_SPU | secHw_BLK_MASK_PKA | secHw_BLK_MASK_RNG | secHw_BLK_MASK_RTC | secHw_BLK_MASK_OTP | secHw_BLK_MASK_BOOT | secHw_BLK_MASK_MPU | secHw_BLK_MASK_TZCTRL | secHw_BLK_MASK_INTR); bus_clock = chipcHw_REG_BUS_CLOCK_GE | chipcHw_REG_BUS_CLOCK_SDIO0 | chipcHw_REG_BUS_CLOCK_SDIO1; chipcHw_busInterfaceClockEnable(bus_clock); for (i = 0; i < ARRAY_SIZE(lookups); i++) clkdev_add(&lookups[i]); for (i = 0; i < ARRAY_SIZE(amba_devs); i++) { struct amba_device *d = amba_devs[i]; amba_device_register(d, &iomem_resource); } }