Lines Matching refs:bus
71 static int ssb_pcmcia_cfg_write(struct ssb_bus *bus, u8 offset, u8 value) in ssb_pcmcia_cfg_write() argument
75 res = pcmcia_write_config_byte(bus->host_pcmcia, offset, value); in ssb_pcmcia_cfg_write()
83 static int ssb_pcmcia_cfg_read(struct ssb_bus *bus, u8 offset, u8 *value) in ssb_pcmcia_cfg_read() argument
87 res = pcmcia_read_config_byte(bus->host_pcmcia, offset, value); in ssb_pcmcia_cfg_read()
94 int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus, in ssb_pcmcia_switch_coreidx() argument
106 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_ADDRESS0, in ssb_pcmcia_switch_coreidx()
110 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_ADDRESS1, in ssb_pcmcia_switch_coreidx()
114 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_ADDRESS2, in ssb_pcmcia_switch_coreidx()
121 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_ADDRESS0, &val); in ssb_pcmcia_switch_coreidx()
125 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_ADDRESS1, &val); in ssb_pcmcia_switch_coreidx()
129 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_ADDRESS2, &val); in ssb_pcmcia_switch_coreidx()
150 static int ssb_pcmcia_switch_core(struct ssb_bus *bus, struct ssb_device *dev) in ssb_pcmcia_switch_core() argument
159 err = ssb_pcmcia_switch_coreidx(bus, dev->core_index); in ssb_pcmcia_switch_core()
161 bus->mapped_device = dev; in ssb_pcmcia_switch_core()
166 int ssb_pcmcia_switch_segment(struct ssb_bus *bus, u8 seg) in ssb_pcmcia_switch_segment() argument
174 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_MEMSEG, seg); in ssb_pcmcia_switch_segment()
177 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_MEMSEG, &val); in ssb_pcmcia_switch_segment()
188 bus->mapped_pcmcia_seg = seg; in ssb_pcmcia_switch_segment()
199 struct ssb_bus *bus = dev->bus; in select_core_and_segment() local
209 if (unlikely(dev != bus->mapped_device)) { in select_core_and_segment()
210 err = ssb_pcmcia_switch_core(bus, dev); in select_core_and_segment()
214 if (unlikely(need_segment != bus->mapped_pcmcia_seg)) { in select_core_and_segment()
215 err = ssb_pcmcia_switch_segment(bus, need_segment); in select_core_and_segment()
225 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_read8() local
230 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_read8()
233 value = readb(bus->mmio + offset); in ssb_pcmcia_read8()
234 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_read8()
241 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_read16() local
246 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_read16()
249 value = readw(bus->mmio + offset); in ssb_pcmcia_read16()
250 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_read16()
257 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_read32() local
262 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_read32()
265 lo = readw(bus->mmio + offset); in ssb_pcmcia_read32()
266 hi = readw(bus->mmio + offset + 2); in ssb_pcmcia_read32()
268 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_read32()
277 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_block_read() local
279 void __iomem *addr = bus->mmio + offset; in ssb_pcmcia_block_read()
282 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_block_read()
327 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_block_read()
333 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_write8() local
337 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_write8()
340 writeb(value, bus->mmio + offset); in ssb_pcmcia_write8()
341 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_write8()
346 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_write16() local
350 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_write16()
353 writew(value, bus->mmio + offset); in ssb_pcmcia_write16()
354 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_write16()
359 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_write32() local
363 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_write32()
366 writew((value & 0x0000FFFF), bus->mmio + offset); in ssb_pcmcia_write32()
367 writew(((value & 0xFFFF0000) >> 16), bus->mmio + offset + 2); in ssb_pcmcia_write32()
369 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_write32()
376 struct ssb_bus *bus = dev->bus; in ssb_pcmcia_block_write() local
378 void __iomem *addr = bus->mmio + offset; in ssb_pcmcia_block_write()
381 spin_lock_irqsave(&bus->bar_lock, flags); in ssb_pcmcia_block_write()
424 spin_unlock_irqrestore(&bus->bar_lock, flags); in ssb_pcmcia_block_write()
442 static int ssb_pcmcia_sprom_command(struct ssb_bus *bus, u8 command) in ssb_pcmcia_sprom_command() argument
448 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROMCTL, command); in ssb_pcmcia_sprom_command()
452 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_SPROMCTL, &value); in ssb_pcmcia_sprom_command()
464 static int ssb_pcmcia_sprom_read(struct ssb_bus *bus, u16 offset, u16 *value) in ssb_pcmcia_sprom_read() argument
471 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_ADDRLO, in ssb_pcmcia_sprom_read()
475 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_ADDRHI, in ssb_pcmcia_sprom_read()
479 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_READ); in ssb_pcmcia_sprom_read()
482 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_SPROM_DATALO, &lo); in ssb_pcmcia_sprom_read()
485 err = ssb_pcmcia_cfg_read(bus, SSB_PCMCIA_SPROM_DATAHI, &hi); in ssb_pcmcia_sprom_read()
494 static int ssb_pcmcia_sprom_write(struct ssb_bus *bus, u16 offset, u16 value) in ssb_pcmcia_sprom_write() argument
500 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_ADDRLO, in ssb_pcmcia_sprom_write()
504 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_ADDRHI, in ssb_pcmcia_sprom_write()
508 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_DATALO, in ssb_pcmcia_sprom_write()
512 err = ssb_pcmcia_cfg_write(bus, SSB_PCMCIA_SPROM_DATAHI, in ssb_pcmcia_sprom_write()
516 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITE); in ssb_pcmcia_sprom_write()
525 static int ssb_pcmcia_sprom_read_all(struct ssb_bus *bus, u16 *sprom) in ssb_pcmcia_sprom_read_all() argument
530 err = ssb_pcmcia_sprom_read(bus, i, &sprom[i]); in ssb_pcmcia_sprom_read_all()
539 static int ssb_pcmcia_sprom_write_all(struct ssb_bus *bus, const u16 *sprom) in ssb_pcmcia_sprom_write_all() argument
546 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEEN); in ssb_pcmcia_sprom_write_all()
562 err = ssb_pcmcia_sprom_write(bus, i, sprom[i]); in ssb_pcmcia_sprom_write_all()
569 err = ssb_pcmcia_sprom_command(bus, SSB_PCMCIA_SPROMCTL_WRITEDIS); in ssb_pcmcia_sprom_write_all()
697 int ssb_pcmcia_get_invariants(struct ssb_bus *bus, in ssb_pcmcia_get_invariants() argument
709 res = pcmcia_loop_tuple(bus->host_pcmcia, CISTPL_FUNCE, in ssb_pcmcia_get_invariants()
717 res = pcmcia_loop_tuple(bus->host_pcmcia, SSB_PCMCIA_CIS, in ssb_pcmcia_get_invariants()
732 struct ssb_bus *bus; in ssb_sprom_show() local
734 bus = ssb_pcmcia_dev_to_bus(pdev); in ssb_sprom_show()
735 if (!bus) in ssb_sprom_show()
738 return ssb_attr_sprom_show(bus, buf, in ssb_sprom_show()
748 struct ssb_bus *bus; in ssb_sprom_store() local
750 bus = ssb_pcmcia_dev_to_bus(pdev); in ssb_sprom_store()
751 if (!bus) in ssb_sprom_store()
754 return ssb_attr_sprom_store(bus, buf, count, in ssb_sprom_store()
761 static int ssb_pcmcia_cor_setup(struct ssb_bus *bus, u8 cor) in ssb_pcmcia_cor_setup() argument
766 err = ssb_pcmcia_cfg_read(bus, cor, &val); in ssb_pcmcia_cor_setup()
771 err = ssb_pcmcia_cfg_write(bus, cor, val); in ssb_pcmcia_cor_setup()
780 int ssb_pcmcia_hardware_setup(struct ssb_bus *bus) in ssb_pcmcia_hardware_setup() argument
784 if (bus->bustype != SSB_BUSTYPE_PCMCIA) in ssb_pcmcia_hardware_setup()
789 ssb_pcmcia_switch_segment(bus, 0); in ssb_pcmcia_hardware_setup()
791 err = ssb_pcmcia_cor_setup(bus, CISREG_COR); in ssb_pcmcia_hardware_setup()
795 err = ssb_pcmcia_cor_setup(bus, CISREG_COR + 0x80); in ssb_pcmcia_hardware_setup()
802 void ssb_pcmcia_exit(struct ssb_bus *bus) in ssb_pcmcia_exit() argument
804 if (bus->bustype != SSB_BUSTYPE_PCMCIA) in ssb_pcmcia_exit()
807 device_remove_file(&bus->host_pcmcia->dev, &dev_attr_ssb_sprom); in ssb_pcmcia_exit()
810 int ssb_pcmcia_init(struct ssb_bus *bus) in ssb_pcmcia_init() argument
814 if (bus->bustype != SSB_BUSTYPE_PCMCIA) in ssb_pcmcia_init()
817 err = ssb_pcmcia_hardware_setup(bus); in ssb_pcmcia_init()
821 bus->sprom_size = SSB_PCMCIA_SPROM_SIZE; in ssb_pcmcia_init()
822 mutex_init(&bus->sprom_mutex); in ssb_pcmcia_init()
823 err = device_create_file(&bus->host_pcmcia->dev, &dev_attr_ssb_sprom); in ssb_pcmcia_init()