Lines Matching refs:cc

18 static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,  in bcma_cc_write32_masked()  argument
22 value |= bcma_cc_read32(cc, offset) & ~mask; in bcma_cc_write32_masked()
23 bcma_cc_write32(cc, offset, value); in bcma_cc_write32_masked()
28 u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc) in bcma_chipco_get_alp_clock() argument
30 if (cc->capabilities & BCMA_CC_CAP_PMU) in bcma_chipco_get_alp_clock()
31 return bcma_pmu_get_alp_clock(cc); in bcma_chipco_get_alp_clock()
37 static bool bcma_core_cc_has_pmu_watchdog(struct bcma_drv_cc *cc) in bcma_core_cc_has_pmu_watchdog() argument
39 struct bcma_bus *bus = cc->core->bus; in bcma_core_cc_has_pmu_watchdog()
41 if (cc->capabilities & BCMA_CC_CAP_PMU) { in bcma_core_cc_has_pmu_watchdog()
56 static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc) in bcma_chipco_watchdog_get_max_timer() argument
58 struct bcma_bus *bus = cc->core->bus; in bcma_chipco_watchdog_get_max_timer()
61 if (bcma_core_cc_has_pmu_watchdog(cc)) { in bcma_chipco_watchdog_get_max_timer()
64 else if (cc->core->id.rev < 26) in bcma_chipco_watchdog_get_max_timer()
67 nb = (cc->core->id.rev >= 37) ? 32 : 24; in bcma_chipco_watchdog_get_max_timer()
80 struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt); in bcma_chipco_watchdog_timer_set_wdt() local
82 return bcma_chipco_watchdog_timer_set(cc, ticks); in bcma_chipco_watchdog_timer_set_wdt()
88 struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt); in bcma_chipco_watchdog_timer_set_ms_wdt() local
91 ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms); in bcma_chipco_watchdog_timer_set_ms_wdt()
92 return ticks / cc->ticks_per_ms; in bcma_chipco_watchdog_timer_set_ms_wdt()
95 static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc) in bcma_chipco_watchdog_ticks_per_ms() argument
97 struct bcma_bus *bus = cc->core->bus; in bcma_chipco_watchdog_ticks_per_ms()
99 if (cc->capabilities & BCMA_CC_CAP_PMU) { in bcma_chipco_watchdog_ticks_per_ms()
104 return bcma_chipco_get_alp_clock(cc) / 4000; in bcma_chipco_watchdog_ticks_per_ms()
109 return bcma_chipco_get_alp_clock(cc) / 1000; in bcma_chipco_watchdog_ticks_per_ms()
113 int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc) in bcma_chipco_watchdog_register() argument
115 struct bcma_bus *bus = cc->core->bus; in bcma_chipco_watchdog_register()
125 wdt.driver_data = cc; in bcma_chipco_watchdog_register()
129 bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms; in bcma_chipco_watchdog_register()
137 cc->watchdog = pdev; in bcma_chipco_watchdog_register()
142 static void bcma_core_chipcommon_flash_detect(struct bcma_drv_cc *cc) in bcma_core_chipcommon_flash_detect() argument
144 struct bcma_bus *bus = cc->core->bus; in bcma_core_chipcommon_flash_detect()
146 switch (cc->capabilities & BCMA_CC_CAP_FLASHT) { in bcma_core_chipcommon_flash_detect()
150 bcma_sflash_init(cc); in bcma_core_chipcommon_flash_detect()
154 bcma_pflash_init(cc); in bcma_core_chipcommon_flash_detect()
160 if (cc->core->id.rev == 38 || in bcma_core_chipcommon_flash_detect()
162 if (cc->capabilities & BCMA_CC_CAP_NFLASH) { in bcma_core_chipcommon_flash_detect()
164 bcma_nflash_init(cc); in bcma_core_chipcommon_flash_detect()
169 void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc) in bcma_core_chipcommon_early_init() argument
171 struct bcma_bus *bus = cc->core->bus; in bcma_core_chipcommon_early_init()
173 if (cc->early_setup_done) in bcma_core_chipcommon_early_init()
176 spin_lock_init(&cc->gpio_lock); in bcma_core_chipcommon_early_init()
178 if (cc->core->id.rev >= 11) in bcma_core_chipcommon_early_init()
179 cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT); in bcma_core_chipcommon_early_init()
180 cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP); in bcma_core_chipcommon_early_init()
181 if (cc->core->id.rev >= 35) in bcma_core_chipcommon_early_init()
182 cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT); in bcma_core_chipcommon_early_init()
184 if (cc->capabilities & BCMA_CC_CAP_PMU) in bcma_core_chipcommon_early_init()
185 bcma_pmu_early_init(cc); in bcma_core_chipcommon_early_init()
188 bcma_core_chipcommon_flash_detect(cc); in bcma_core_chipcommon_early_init()
190 cc->early_setup_done = true; in bcma_core_chipcommon_early_init()
193 void bcma_core_chipcommon_init(struct bcma_drv_cc *cc) in bcma_core_chipcommon_init() argument
198 if (cc->setup_done) in bcma_core_chipcommon_init()
201 bcma_core_chipcommon_early_init(cc); in bcma_core_chipcommon_init()
203 if (cc->core->id.rev >= 20) { in bcma_core_chipcommon_init()
206 if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) { in bcma_core_chipcommon_init()
211 bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup); in bcma_core_chipcommon_init()
212 bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown); in bcma_core_chipcommon_init()
215 if (cc->capabilities & BCMA_CC_CAP_PMU) in bcma_core_chipcommon_init()
216 bcma_pmu_init(cc); in bcma_core_chipcommon_init()
217 if (cc->capabilities & BCMA_CC_CAP_PCTL) in bcma_core_chipcommon_init()
218 bcma_err(cc->core->bus, "Power control not implemented!\n"); in bcma_core_chipcommon_init()
220 if (cc->core->id.rev >= 16) { in bcma_core_chipcommon_init()
221 if (cc->core->bus->sprom.leddc_on_time && in bcma_core_chipcommon_init()
222 cc->core->bus->sprom.leddc_off_time) { in bcma_core_chipcommon_init()
223 leddc_on = cc->core->bus->sprom.leddc_on_time; in bcma_core_chipcommon_init()
224 leddc_off = cc->core->bus->sprom.leddc_off_time; in bcma_core_chipcommon_init()
226 bcma_cc_write32(cc, BCMA_CC_GPIOTIMER, in bcma_core_chipcommon_init()
230 cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc); in bcma_core_chipcommon_init()
232 cc->setup_done = true; in bcma_core_chipcommon_init()
236 u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks) in bcma_chipco_watchdog_timer_set() argument
240 maxt = bcma_chipco_watchdog_get_max_timer(cc); in bcma_chipco_watchdog_timer_set()
241 if (bcma_core_cc_has_pmu_watchdog(cc)) { in bcma_chipco_watchdog_timer_set()
246 bcma_pmu_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks); in bcma_chipco_watchdog_timer_set()
248 struct bcma_bus *bus = cc->core->bus; in bcma_chipco_watchdog_timer_set()
253 bcma_core_set_clockmode(cc->core, in bcma_chipco_watchdog_timer_set()
259 bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks); in bcma_chipco_watchdog_timer_set()
264 void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_irq_mask() argument
266 bcma_cc_write32_masked(cc, BCMA_CC_IRQMASK, mask, value); in bcma_chipco_irq_mask()
269 u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask) in bcma_chipco_irq_status() argument
271 return bcma_cc_read32(cc, BCMA_CC_IRQSTAT) & mask; in bcma_chipco_irq_status()
274 u32 bcma_chipco_gpio_in(struct bcma_drv_cc *cc, u32 mask) in bcma_chipco_gpio_in() argument
276 return bcma_cc_read32(cc, BCMA_CC_GPIOIN) & mask; in bcma_chipco_gpio_in()
279 u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_out() argument
284 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_out()
285 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value); in bcma_chipco_gpio_out()
286 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_out()
292 u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_outen() argument
297 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_outen()
298 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value); in bcma_chipco_gpio_outen()
299 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_outen()
309 u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_control() argument
314 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_control()
315 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value); in bcma_chipco_gpio_control()
316 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_control()
322 u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_intmask() argument
327 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_intmask()
328 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value); in bcma_chipco_gpio_intmask()
329 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_intmask()
334 u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_polarity() argument
339 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_polarity()
340 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value); in bcma_chipco_gpio_polarity()
341 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_polarity()
346 u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_pullup() argument
351 if (cc->core->id.rev < 20) in bcma_chipco_gpio_pullup()
354 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_pullup()
355 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value); in bcma_chipco_gpio_pullup()
356 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_pullup()
361 u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value) in bcma_chipco_gpio_pulldown() argument
366 if (cc->core->id.rev < 20) in bcma_chipco_gpio_pulldown()
369 spin_lock_irqsave(&cc->gpio_lock, flags); in bcma_chipco_gpio_pulldown()
370 res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value); in bcma_chipco_gpio_pulldown()
371 spin_unlock_irqrestore(&cc->gpio_lock, flags); in bcma_chipco_gpio_pulldown()
377 void bcma_chipco_serial_init(struct bcma_drv_cc *cc) in bcma_chipco_serial_init() argument
382 unsigned int ccrev = cc->core->id.rev; in bcma_chipco_serial_init()
383 struct bcma_serial_port *ports = cc->serial_ports; in bcma_chipco_serial_init()
386 baud_base = bcma_chipco_get_alp_clock(cc); in bcma_chipco_serial_init()
389 bcma_cc_write32(cc, BCMA_CC_CORECTL, in bcma_chipco_serial_init()
390 bcma_cc_read32(cc, BCMA_CC_CORECTL) in bcma_chipco_serial_init()
394 bcma_cc_write32(cc, BCMA_CC_CORECTL, in bcma_chipco_serial_init()
395 bcma_cc_read32(cc, BCMA_CC_CORECTL) in bcma_chipco_serial_init()
399 bcma_cc_write32(cc, BCMA_CC_CORECTL, in bcma_chipco_serial_init()
400 bcma_cc_read32(cc, BCMA_CC_CORECTL) in bcma_chipco_serial_init()
404 bcma_err(cc->core->bus, "serial not supported on this device ccrev: 0x%x\n", in bcma_chipco_serial_init()
409 irq = bcma_core_irq(cc->core, 0); in bcma_chipco_serial_init()
412 cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART); in bcma_chipco_serial_init()
413 for (i = 0; i < cc->nr_serial_ports; i++) { in bcma_chipco_serial_init()
414 ports[i].regs = cc->core->io_addr + BCMA_CC_UART0_DATA + in bcma_chipco_serial_init()