2 * Sonics Silicon Backplane
3 * PCMCIA-Hostbus related functions
5 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
6 * Copyright 2007-2008 Michael Buesch <mb@bu3sch.de>
8 * Licensed under the GNU/GPL. See COPYING for details.
11 #include <linux/ssb/ssb.h>
12 #include <linux/delay.h>
14 #include <linux/etherdevice.h>
16 #include <pcmcia/cs.h>
17 #include <pcmcia/cistpl.h>
18 #include <pcmcia/ciscode.h>
19 #include <pcmcia/ds.h>
20 #include <pcmcia/cisreg.h>
22 #include "ssb_private.h"
25 /* Define the following to 1 to enable a printk on each coreswitch. */
26 #define SSB_VERBOSE_PCMCIACORESWITCH_DEBUG 0
29 /* PCMCIA configuration registers */
30 #define SSB_PCMCIA_ADDRESS0 0x2E
31 #define SSB_PCMCIA_ADDRESS1 0x30
32 #define SSB_PCMCIA_ADDRESS2 0x32
33 #define SSB_PCMCIA_MEMSEG 0x34
34 #define SSB_PCMCIA_SPROMCTL 0x36
35 #define SSB_PCMCIA_SPROMCTL_IDLE 0
36 #define SSB_PCMCIA_SPROMCTL_WRITE 1
37 #define SSB_PCMCIA_SPROMCTL_READ 2
38 #define SSB_PCMCIA_SPROMCTL_WRITEEN 4
39 #define SSB_PCMCIA_SPROMCTL_WRITEDIS 7
40 #define SSB_PCMCIA_SPROMCTL_DONE 8
41 #define SSB_PCMCIA_SPROM_DATALO 0x38
42 #define SSB_PCMCIA_SPROM_DATAHI 0x3A
43 #define SSB_PCMCIA_SPROM_ADDRLO 0x3C
44 #define SSB_PCMCIA_SPROM_ADDRHI 0x3E
46 /* Hardware invariants CIS tuples */
47 #define SSB_PCMCIA_CIS 0x80
48 #define SSB_PCMCIA_CIS_ID 0x01
49 #define SSB_PCMCIA_CIS_BOARDREV 0x02
50 #define SSB_PCMCIA_CIS_PA 0x03
51 #define SSB_PCMCIA_CIS_PA_PA0B0_LO 0
52 #define SSB_PCMCIA_CIS_PA_PA0B0_HI 1
53 #define SSB_PCMCIA_CIS_PA_PA0B1_LO 2
54 #define SSB_PCMCIA_CIS_PA_PA0B1_HI 3
55 #define SSB_PCMCIA_CIS_PA_PA0B2_LO 4
56 #define SSB_PCMCIA_CIS_PA_PA0B2_HI 5
57 #define SSB_PCMCIA_CIS_PA_ITSSI 6
58 #define SSB_PCMCIA_CIS_PA_MAXPOW 7
59 #define SSB_PCMCIA_CIS_OEMNAME 0x04
60 #define SSB_PCMCIA_CIS_CCODE 0x05
61 #define SSB_PCMCIA_CIS_ANTENNA 0x06
62 #define SSB_PCMCIA_CIS_ANTGAIN 0x07
63 #define SSB_PCMCIA_CIS_BFLAGS 0x08
64 #define SSB_PCMCIA_CIS_LEDS 0x09
66 /* PCMCIA SPROM size. */
67 #define SSB_PCMCIA_SPROM_SIZE 256
68 #define SSB_PCMCIA_SPROM_SIZE_BYTES (SSB_PCMCIA_SPROM_SIZE * sizeof(u16))
71 /* Write to a PCMCIA configuration register. */
72 static int ssb_pcmcia_cfg_write(struct ssb_bus
*bus
, u8 offset
, u8 value
)
76 res
= pcmcia_write_config_byte(bus
->host_pcmcia
, offset
, value
);
77 if (unlikely(res
!= 0))
83 /* Read from a PCMCIA configuration register. */
84 static int ssb_pcmcia_cfg_read(struct ssb_bus
*bus
, u8 offset
, u8
*value
)
88 res
= pcmcia_read_config_byte(bus
->host_pcmcia
, offset
, value
);
89 if (unlikely(res
!= 0))
95 int ssb_pcmcia_switch_coreidx(struct ssb_bus
*bus
,
105 addr
= (coreidx
* SSB_CORE_SIZE
) + SSB_ENUM_BASE
;
107 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS0
,
108 (addr
& 0x0000F000) >> 12);
111 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS1
,
112 (addr
& 0x00FF0000) >> 16);
115 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS2
,
116 (addr
& 0xFF000000) >> 24);
122 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS0
, &val
);
125 read_addr
|= ((u32
)(val
& 0x0F)) << 12;
126 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS1
, &val
);
129 read_addr
|= ((u32
)val
) << 16;
130 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS2
, &val
);
133 read_addr
|= ((u32
)val
) << 24;
135 cur_core
= (read_addr
- SSB_ENUM_BASE
) / SSB_CORE_SIZE
;
136 if (cur_core
== coreidx
)
140 if (attempts
++ > SSB_BAR0_MAX_RETRIES
)
147 ssb_printk(KERN_ERR PFX
"Failed to switch to core %u\n", coreidx
);
151 int ssb_pcmcia_switch_core(struct ssb_bus
*bus
,
152 struct ssb_device
*dev
)
156 #if SSB_VERBOSE_PCMCIACORESWITCH_DEBUG
157 ssb_printk(KERN_INFO PFX
158 "Switching to %s core, index %d\n",
159 ssb_core_name(dev
->id
.coreid
),
163 err
= ssb_pcmcia_switch_coreidx(bus
, dev
->core_index
);
165 bus
->mapped_device
= dev
;
170 int ssb_pcmcia_switch_segment(struct ssb_bus
*bus
, u8 seg
)
176 SSB_WARN_ON((seg
!= 0) && (seg
!= 1));
178 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_MEMSEG
, seg
);
181 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_MEMSEG
, &val
);
188 if (unlikely(attempts
++ > SSB_BAR0_MAX_RETRIES
))
192 bus
->mapped_pcmcia_seg
= seg
;
196 ssb_printk(KERN_ERR PFX
"Failed to switch pcmcia segment\n");
200 static int select_core_and_segment(struct ssb_device
*dev
,
203 struct ssb_bus
*bus
= dev
->bus
;
207 if (*offset
>= 0x800) {
213 if (unlikely(dev
!= bus
->mapped_device
)) {
214 err
= ssb_pcmcia_switch_core(bus
, dev
);
218 if (unlikely(need_segment
!= bus
->mapped_pcmcia_seg
)) {
219 err
= ssb_pcmcia_switch_segment(bus
, need_segment
);
227 static u8
ssb_pcmcia_read8(struct ssb_device
*dev
, u16 offset
)
229 struct ssb_bus
*bus
= dev
->bus
;
234 spin_lock_irqsave(&bus
->bar_lock
, flags
);
235 err
= select_core_and_segment(dev
, &offset
);
237 value
= readb(bus
->mmio
+ offset
);
238 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
243 static u16
ssb_pcmcia_read16(struct ssb_device
*dev
, u16 offset
)
245 struct ssb_bus
*bus
= dev
->bus
;
250 spin_lock_irqsave(&bus
->bar_lock
, flags
);
251 err
= select_core_and_segment(dev
, &offset
);
253 value
= readw(bus
->mmio
+ offset
);
254 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
259 static u32
ssb_pcmcia_read32(struct ssb_device
*dev
, u16 offset
)
261 struct ssb_bus
*bus
= dev
->bus
;
264 u32 lo
= 0xFFFFFFFF, hi
= 0xFFFFFFFF;
266 spin_lock_irqsave(&bus
->bar_lock
, flags
);
267 err
= select_core_and_segment(dev
, &offset
);
269 lo
= readw(bus
->mmio
+ offset
);
270 hi
= readw(bus
->mmio
+ offset
+ 2);
272 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
274 return (lo
| (hi
<< 16));
277 #ifdef CONFIG_SSB_BLOCKIO
278 static void ssb_pcmcia_block_read(struct ssb_device
*dev
, void *buffer
,
279 size_t count
, u16 offset
, u8 reg_width
)
281 struct ssb_bus
*bus
= dev
->bus
;
283 void __iomem
*addr
= bus
->mmio
+ offset
;
286 spin_lock_irqsave(&bus
->bar_lock
, flags
);
287 err
= select_core_and_segment(dev
, &offset
);
289 memset(buffer
, 0xFF, count
);
297 *buf
= __raw_readb(addr
);
304 __le16
*buf
= buffer
;
306 SSB_WARN_ON(count
& 1);
308 *buf
= (__force __le16
)__raw_readw(addr
);
315 __le16
*buf
= buffer
;
317 SSB_WARN_ON(count
& 3);
319 *buf
= (__force __le16
)__raw_readw(addr
);
321 *buf
= (__force __le16
)__raw_readw(addr
+ 2);
331 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
333 #endif /* CONFIG_SSB_BLOCKIO */
335 static void ssb_pcmcia_write8(struct ssb_device
*dev
, u16 offset
, u8 value
)
337 struct ssb_bus
*bus
= dev
->bus
;
341 spin_lock_irqsave(&bus
->bar_lock
, flags
);
342 err
= select_core_and_segment(dev
, &offset
);
344 writeb(value
, bus
->mmio
+ offset
);
346 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
349 static void ssb_pcmcia_write16(struct ssb_device
*dev
, u16 offset
, u16 value
)
351 struct ssb_bus
*bus
= dev
->bus
;
355 spin_lock_irqsave(&bus
->bar_lock
, flags
);
356 err
= select_core_and_segment(dev
, &offset
);
358 writew(value
, bus
->mmio
+ offset
);
360 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
363 static void ssb_pcmcia_write32(struct ssb_device
*dev
, u16 offset
, u32 value
)
365 struct ssb_bus
*bus
= dev
->bus
;
369 spin_lock_irqsave(&bus
->bar_lock
, flags
);
370 err
= select_core_and_segment(dev
, &offset
);
372 writew((value
& 0x0000FFFF), bus
->mmio
+ offset
);
373 writew(((value
& 0xFFFF0000) >> 16), bus
->mmio
+ offset
+ 2);
376 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
379 #ifdef CONFIG_SSB_BLOCKIO
380 static void ssb_pcmcia_block_write(struct ssb_device
*dev
, const void *buffer
,
381 size_t count
, u16 offset
, u8 reg_width
)
383 struct ssb_bus
*bus
= dev
->bus
;
385 void __iomem
*addr
= bus
->mmio
+ offset
;
388 spin_lock_irqsave(&bus
->bar_lock
, flags
);
389 err
= select_core_and_segment(dev
, &offset
);
394 const u8
*buf
= buffer
;
397 __raw_writeb(*buf
, addr
);
404 const __le16
*buf
= buffer
;
406 SSB_WARN_ON(count
& 1);
408 __raw_writew((__force u16
)(*buf
), addr
);
415 const __le16
*buf
= buffer
;
417 SSB_WARN_ON(count
& 3);
419 __raw_writew((__force u16
)(*buf
), addr
);
421 __raw_writew((__force u16
)(*buf
), addr
+ 2);
432 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
434 #endif /* CONFIG_SSB_BLOCKIO */
436 /* Not "static", as it's used in main.c */
437 const struct ssb_bus_ops ssb_pcmcia_ops
= {
438 .read8
= ssb_pcmcia_read8
,
439 .read16
= ssb_pcmcia_read16
,
440 .read32
= ssb_pcmcia_read32
,
441 .write8
= ssb_pcmcia_write8
,
442 .write16
= ssb_pcmcia_write16
,
443 .write32
= ssb_pcmcia_write32
,
444 #ifdef CONFIG_SSB_BLOCKIO
445 .block_read
= ssb_pcmcia_block_read
,
446 .block_write
= ssb_pcmcia_block_write
,
450 static int ssb_pcmcia_sprom_command(struct ssb_bus
*bus
, u8 command
)
456 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROMCTL
, command
);
459 for (i
= 0; i
< 1000; i
++) {
460 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROMCTL
, &value
);
463 if (value
& SSB_PCMCIA_SPROMCTL_DONE
)
471 /* offset is the 16bit word offset */
472 static int ssb_pcmcia_sprom_read(struct ssb_bus
*bus
, u16 offset
, u16
*value
)
477 offset
*= 2; /* Make byte offset */
479 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRLO
,
483 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRHI
,
484 (offset
& 0xFF00) >> 8);
487 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_READ
);
490 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROM_DATALO
, &lo
);
493 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROM_DATAHI
, &hi
);
496 *value
= (lo
| (((u16
)hi
) << 8));
501 /* offset is the 16bit word offset */
502 static int ssb_pcmcia_sprom_write(struct ssb_bus
*bus
, u16 offset
, u16 value
)
506 offset
*= 2; /* Make byte offset */
508 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRLO
,
512 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRHI
,
513 (offset
& 0xFF00) >> 8);
516 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_DATALO
,
520 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_DATAHI
,
521 (value
& 0xFF00) >> 8);
524 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITE
);
532 /* Read the SPROM image. bufsize is in 16bit words. */
533 static int ssb_pcmcia_sprom_read_all(struct ssb_bus
*bus
, u16
*sprom
)
537 for (i
= 0; i
< SSB_PCMCIA_SPROM_SIZE
; i
++) {
538 err
= ssb_pcmcia_sprom_read(bus
, i
, &sprom
[i
]);
546 /* Write the SPROM image. size is in 16bit words. */
547 static int ssb_pcmcia_sprom_write_all(struct ssb_bus
*bus
, const u16
*sprom
)
551 size_t size
= SSB_PCMCIA_SPROM_SIZE
;
553 ssb_printk(KERN_NOTICE PFX
554 "Writing SPROM. Do NOT turn off the power! "
555 "Please stand by...\n");
556 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITEEN
);
558 ssb_printk(KERN_NOTICE PFX
559 "Could not enable SPROM write access.\n");
562 ssb_printk(KERN_NOTICE PFX
"[ 0%%");
564 for (i
= 0; i
< size
; i
++) {
567 else if (i
== size
/ 2)
569 else if (i
== (size
* 3) / 4)
573 err
= ssb_pcmcia_sprom_write(bus
, i
, sprom
[i
]);
575 ssb_printk(KERN_NOTICE PFX
576 "Failed to write to SPROM.\n");
581 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITEDIS
);
583 ssb_printk(KERN_NOTICE PFX
584 "Could not disable SPROM write access.\n");
589 ssb_printk("100%% ]\n");
590 ssb_printk(KERN_NOTICE PFX
"SPROM written.\n");
593 return failed
? -EBUSY
: 0;
596 static int ssb_pcmcia_sprom_check_crc(const u16
*sprom
, size_t size
)
602 #define GOTO_ERROR_ON(condition, description) do { \
603 if (unlikely(condition)) { \
604 error_description = description; \
609 static int ssb_pcmcia_get_mac(struct pcmcia_device
*p_dev
,
613 struct ssb_sprom
*sprom
= priv
;
615 if (tuple
->TupleData
[0] != CISTPL_FUNCE_LAN_NODE_ID
)
617 if (tuple
->TupleDataLen
!= ETH_ALEN
+ 2)
619 if (tuple
->TupleData
[1] != ETH_ALEN
)
621 memcpy(sprom
->il0mac
, &tuple
->TupleData
[2], ETH_ALEN
);
625 static int ssb_pcmcia_do_get_invariants(struct pcmcia_device
*p_dev
,
629 struct ssb_init_invariants
*iv
= priv
;
630 struct ssb_sprom
*sprom
= &iv
->sprom
;
631 struct ssb_boardinfo
*bi
= &iv
->boardinfo
;
632 const char *error_description
;
634 GOTO_ERROR_ON(tuple
->TupleDataLen
< 1, "VEN tpl < 1");
635 switch (tuple
->TupleData
[0]) {
636 case SSB_PCMCIA_CIS_ID
:
637 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 5) &&
638 (tuple
->TupleDataLen
!= 7),
640 bi
->vendor
= tuple
->TupleData
[1] |
641 ((u16
)tuple
->TupleData
[2] << 8);
643 case SSB_PCMCIA_CIS_BOARDREV
:
644 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
645 "boardrev tpl size");
646 sprom
->board_rev
= tuple
->TupleData
[1];
648 case SSB_PCMCIA_CIS_PA
:
649 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 9) &&
650 (tuple
->TupleDataLen
!= 10),
652 sprom
->pa0b0
= tuple
->TupleData
[1] |
653 ((u16
)tuple
->TupleData
[2] << 8);
654 sprom
->pa0b1
= tuple
->TupleData
[3] |
655 ((u16
)tuple
->TupleData
[4] << 8);
656 sprom
->pa0b2
= tuple
->TupleData
[5] |
657 ((u16
)tuple
->TupleData
[6] << 8);
658 sprom
->itssi_a
= tuple
->TupleData
[7];
659 sprom
->itssi_bg
= tuple
->TupleData
[7];
660 sprom
->maxpwr_a
= tuple
->TupleData
[8];
661 sprom
->maxpwr_bg
= tuple
->TupleData
[8];
663 case SSB_PCMCIA_CIS_OEMNAME
:
664 /* We ignore this. */
666 case SSB_PCMCIA_CIS_CCODE
:
667 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
669 sprom
->country_code
= tuple
->TupleData
[1];
671 case SSB_PCMCIA_CIS_ANTENNA
:
672 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
674 sprom
->ant_available_a
= tuple
->TupleData
[1];
675 sprom
->ant_available_bg
= tuple
->TupleData
[1];
677 case SSB_PCMCIA_CIS_ANTGAIN
:
678 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
680 sprom
->antenna_gain
.ghz24
.a0
= tuple
->TupleData
[1];
681 sprom
->antenna_gain
.ghz24
.a1
= tuple
->TupleData
[1];
682 sprom
->antenna_gain
.ghz24
.a2
= tuple
->TupleData
[1];
683 sprom
->antenna_gain
.ghz24
.a3
= tuple
->TupleData
[1];
684 sprom
->antenna_gain
.ghz5
.a0
= tuple
->TupleData
[1];
685 sprom
->antenna_gain
.ghz5
.a1
= tuple
->TupleData
[1];
686 sprom
->antenna_gain
.ghz5
.a2
= tuple
->TupleData
[1];
687 sprom
->antenna_gain
.ghz5
.a3
= tuple
->TupleData
[1];
689 case SSB_PCMCIA_CIS_BFLAGS
:
690 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 3) &&
691 (tuple
->TupleDataLen
!= 5),
693 sprom
->boardflags_lo
= tuple
->TupleData
[1] |
694 ((u16
)tuple
->TupleData
[2] << 8);
696 case SSB_PCMCIA_CIS_LEDS
:
697 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 5,
699 sprom
->gpio0
= tuple
->TupleData
[1];
700 sprom
->gpio1
= tuple
->TupleData
[2];
701 sprom
->gpio2
= tuple
->TupleData
[3];
702 sprom
->gpio3
= tuple
->TupleData
[4];
705 return -ENOSPC
; /* continue with next entry */
708 ssb_printk(KERN_ERR PFX
709 "PCMCIA: Failed to fetch device invariants: %s\n",
715 int ssb_pcmcia_get_invariants(struct ssb_bus
*bus
,
716 struct ssb_init_invariants
*iv
)
718 struct ssb_sprom
*sprom
= &iv
->sprom
;
721 memset(sprom
, 0xFF, sizeof(*sprom
));
723 sprom
->boardflags_lo
= 0;
724 sprom
->boardflags_hi
= 0;
726 /* First fetch the MAC address. */
727 res
= pcmcia_loop_tuple(bus
->host_pcmcia
, CISTPL_FUNCE
,
728 ssb_pcmcia_get_mac
, sprom
);
730 ssb_printk(KERN_ERR PFX
731 "PCMCIA: Failed to fetch MAC address\n");
735 /* Fetch the vendor specific tuples. */
736 res
= pcmcia_loop_tuple(bus
->host_pcmcia
, SSB_PCMCIA_CIS
,
737 ssb_pcmcia_do_get_invariants
, sprom
);
738 if ((res
== 0) || (res
== -ENOSPC
))
741 ssb_printk(KERN_ERR PFX
742 "PCMCIA: Failed to fetch device invariants\n");
746 static ssize_t
ssb_pcmcia_attr_sprom_show(struct device
*pcmciadev
,
747 struct device_attribute
*attr
,
750 struct pcmcia_device
*pdev
=
751 container_of(pcmciadev
, struct pcmcia_device
, dev
);
754 bus
= ssb_pcmcia_dev_to_bus(pdev
);
758 return ssb_attr_sprom_show(bus
, buf
,
759 ssb_pcmcia_sprom_read_all
);
762 static ssize_t
ssb_pcmcia_attr_sprom_store(struct device
*pcmciadev
,
763 struct device_attribute
*attr
,
764 const char *buf
, size_t count
)
766 struct pcmcia_device
*pdev
=
767 container_of(pcmciadev
, struct pcmcia_device
, dev
);
770 bus
= ssb_pcmcia_dev_to_bus(pdev
);
774 return ssb_attr_sprom_store(bus
, buf
, count
,
775 ssb_pcmcia_sprom_check_crc
,
776 ssb_pcmcia_sprom_write_all
);
779 static DEVICE_ATTR(ssb_sprom
, 0600,
780 ssb_pcmcia_attr_sprom_show
,
781 ssb_pcmcia_attr_sprom_store
);
783 static int ssb_pcmcia_cor_setup(struct ssb_bus
*bus
, u8 cor
)
788 err
= ssb_pcmcia_cfg_read(bus
, cor
, &val
);
791 val
&= ~COR_SOFT_RESET
;
792 val
|= COR_FUNC_ENA
| COR_IREQ_ENA
| COR_LEVEL_REQ
;
793 err
= ssb_pcmcia_cfg_write(bus
, cor
, val
);
801 /* Initialize the PCMCIA hardware. This is called on Init and Resume. */
802 int ssb_pcmcia_hardware_setup(struct ssb_bus
*bus
)
806 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
809 /* Switch segment to a known state and sync
810 * bus->mapped_pcmcia_seg with hardware state. */
811 ssb_pcmcia_switch_segment(bus
, 0);
812 /* Init the COR register. */
813 err
= ssb_pcmcia_cor_setup(bus
, CISREG_COR
);
816 /* Some cards also need this register to get poked. */
817 err
= ssb_pcmcia_cor_setup(bus
, CISREG_COR
+ 0x80);
824 void ssb_pcmcia_exit(struct ssb_bus
*bus
)
826 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
829 device_remove_file(&bus
->host_pcmcia
->dev
, &dev_attr_ssb_sprom
);
832 int ssb_pcmcia_init(struct ssb_bus
*bus
)
836 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
839 err
= ssb_pcmcia_hardware_setup(bus
);
843 bus
->sprom_size
= SSB_PCMCIA_SPROM_SIZE
;
844 mutex_init(&bus
->sprom_mutex
);
845 err
= device_create_file(&bus
->host_pcmcia
->dev
, &dev_attr_ssb_sprom
);
851 ssb_printk(KERN_ERR PFX
"Failed to initialize PCMCIA host device\n");