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_types.h>
17 #include <pcmcia/cs.h>
18 #include <pcmcia/cistpl.h>
19 #include <pcmcia/ciscode.h>
20 #include <pcmcia/ds.h>
21 #include <pcmcia/cisreg.h>
23 #include "ssb_private.h"
26 /* Define the following to 1 to enable a printk on each coreswitch. */
27 #define SSB_VERBOSE_PCMCIACORESWITCH_DEBUG 0
30 /* PCMCIA configuration registers */
31 #define SSB_PCMCIA_ADDRESS0 0x2E
32 #define SSB_PCMCIA_ADDRESS1 0x30
33 #define SSB_PCMCIA_ADDRESS2 0x32
34 #define SSB_PCMCIA_MEMSEG 0x34
35 #define SSB_PCMCIA_SPROMCTL 0x36
36 #define SSB_PCMCIA_SPROMCTL_IDLE 0
37 #define SSB_PCMCIA_SPROMCTL_WRITE 1
38 #define SSB_PCMCIA_SPROMCTL_READ 2
39 #define SSB_PCMCIA_SPROMCTL_WRITEEN 4
40 #define SSB_PCMCIA_SPROMCTL_WRITEDIS 7
41 #define SSB_PCMCIA_SPROMCTL_DONE 8
42 #define SSB_PCMCIA_SPROM_DATALO 0x38
43 #define SSB_PCMCIA_SPROM_DATAHI 0x3A
44 #define SSB_PCMCIA_SPROM_ADDRLO 0x3C
45 #define SSB_PCMCIA_SPROM_ADDRHI 0x3E
47 /* Hardware invariants CIS tuples */
48 #define SSB_PCMCIA_CIS 0x80
49 #define SSB_PCMCIA_CIS_ID 0x01
50 #define SSB_PCMCIA_CIS_BOARDREV 0x02
51 #define SSB_PCMCIA_CIS_PA 0x03
52 #define SSB_PCMCIA_CIS_PA_PA0B0_LO 0
53 #define SSB_PCMCIA_CIS_PA_PA0B0_HI 1
54 #define SSB_PCMCIA_CIS_PA_PA0B1_LO 2
55 #define SSB_PCMCIA_CIS_PA_PA0B1_HI 3
56 #define SSB_PCMCIA_CIS_PA_PA0B2_LO 4
57 #define SSB_PCMCIA_CIS_PA_PA0B2_HI 5
58 #define SSB_PCMCIA_CIS_PA_ITSSI 6
59 #define SSB_PCMCIA_CIS_PA_MAXPOW 7
60 #define SSB_PCMCIA_CIS_OEMNAME 0x04
61 #define SSB_PCMCIA_CIS_CCODE 0x05
62 #define SSB_PCMCIA_CIS_ANTENNA 0x06
63 #define SSB_PCMCIA_CIS_ANTGAIN 0x07
64 #define SSB_PCMCIA_CIS_BFLAGS 0x08
65 #define SSB_PCMCIA_CIS_LEDS 0x09
67 /* PCMCIA SPROM size. */
68 #define SSB_PCMCIA_SPROM_SIZE 256
69 #define SSB_PCMCIA_SPROM_SIZE_BYTES (SSB_PCMCIA_SPROM_SIZE * sizeof(u16))
72 /* Write to a PCMCIA configuration register. */
73 static int ssb_pcmcia_cfg_write(struct ssb_bus
*bus
, u8 offset
, u8 value
)
78 memset(®
, 0, sizeof(reg
));
80 reg
.Action
= CS_WRITE
;
82 res
= pcmcia_access_configuration_register(bus
->host_pcmcia
, ®
);
83 if (unlikely(res
!= 0))
89 /* Read from a PCMCIA configuration register. */
90 static int ssb_pcmcia_cfg_read(struct ssb_bus
*bus
, u8 offset
, u8
*value
)
95 memset(®
, 0, sizeof(reg
));
98 res
= pcmcia_access_configuration_register(bus
->host_pcmcia
, ®
);
99 if (unlikely(res
!= 0))
106 int ssb_pcmcia_switch_coreidx(struct ssb_bus
*bus
,
116 addr
= (coreidx
* SSB_CORE_SIZE
) + SSB_ENUM_BASE
;
118 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS0
,
119 (addr
& 0x0000F000) >> 12);
122 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS1
,
123 (addr
& 0x00FF0000) >> 16);
126 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_ADDRESS2
,
127 (addr
& 0xFF000000) >> 24);
133 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS0
, &val
);
136 read_addr
|= ((u32
)(val
& 0x0F)) << 12;
137 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS1
, &val
);
140 read_addr
|= ((u32
)val
) << 16;
141 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_ADDRESS2
, &val
);
144 read_addr
|= ((u32
)val
) << 24;
146 cur_core
= (read_addr
- SSB_ENUM_BASE
) / SSB_CORE_SIZE
;
147 if (cur_core
== coreidx
)
151 if (attempts
++ > SSB_BAR0_MAX_RETRIES
)
158 ssb_printk(KERN_ERR PFX
"Failed to switch to core %u\n", coreidx
);
162 int ssb_pcmcia_switch_core(struct ssb_bus
*bus
,
163 struct ssb_device
*dev
)
167 #if SSB_VERBOSE_PCMCIACORESWITCH_DEBUG
168 ssb_printk(KERN_INFO PFX
169 "Switching to %s core, index %d\n",
170 ssb_core_name(dev
->id
.coreid
),
174 err
= ssb_pcmcia_switch_coreidx(bus
, dev
->core_index
);
176 bus
->mapped_device
= dev
;
181 int ssb_pcmcia_switch_segment(struct ssb_bus
*bus
, u8 seg
)
187 SSB_WARN_ON((seg
!= 0) && (seg
!= 1));
189 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_MEMSEG
, seg
);
192 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_MEMSEG
, &val
);
199 if (unlikely(attempts
++ > SSB_BAR0_MAX_RETRIES
))
203 bus
->mapped_pcmcia_seg
= seg
;
207 ssb_printk(KERN_ERR PFX
"Failed to switch pcmcia segment\n");
211 static int select_core_and_segment(struct ssb_device
*dev
,
214 struct ssb_bus
*bus
= dev
->bus
;
218 if (*offset
>= 0x800) {
224 if (unlikely(dev
!= bus
->mapped_device
)) {
225 err
= ssb_pcmcia_switch_core(bus
, dev
);
229 if (unlikely(need_segment
!= bus
->mapped_pcmcia_seg
)) {
230 err
= ssb_pcmcia_switch_segment(bus
, need_segment
);
238 static u8
ssb_pcmcia_read8(struct ssb_device
*dev
, u16 offset
)
240 struct ssb_bus
*bus
= dev
->bus
;
245 spin_lock_irqsave(&bus
->bar_lock
, flags
);
246 err
= select_core_and_segment(dev
, &offset
);
248 value
= readb(bus
->mmio
+ offset
);
249 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
254 static u16
ssb_pcmcia_read16(struct ssb_device
*dev
, u16 offset
)
256 struct ssb_bus
*bus
= dev
->bus
;
261 spin_lock_irqsave(&bus
->bar_lock
, flags
);
262 err
= select_core_and_segment(dev
, &offset
);
264 value
= readw(bus
->mmio
+ offset
);
265 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
270 static u32
ssb_pcmcia_read32(struct ssb_device
*dev
, u16 offset
)
272 struct ssb_bus
*bus
= dev
->bus
;
275 u32 lo
= 0xFFFFFFFF, hi
= 0xFFFFFFFF;
277 spin_lock_irqsave(&bus
->bar_lock
, flags
);
278 err
= select_core_and_segment(dev
, &offset
);
280 lo
= readw(bus
->mmio
+ offset
);
281 hi
= readw(bus
->mmio
+ offset
+ 2);
283 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
285 return (lo
| (hi
<< 16));
288 #ifdef CONFIG_SSB_BLOCKIO
289 static void ssb_pcmcia_block_read(struct ssb_device
*dev
, void *buffer
,
290 size_t count
, u16 offset
, u8 reg_width
)
292 struct ssb_bus
*bus
= dev
->bus
;
294 void __iomem
*addr
= bus
->mmio
+ offset
;
297 spin_lock_irqsave(&bus
->bar_lock
, flags
);
298 err
= select_core_and_segment(dev
, &offset
);
300 memset(buffer
, 0xFF, count
);
308 *buf
= __raw_readb(addr
);
315 __le16
*buf
= buffer
;
317 SSB_WARN_ON(count
& 1);
319 *buf
= (__force __le16
)__raw_readw(addr
);
326 __le16
*buf
= buffer
;
328 SSB_WARN_ON(count
& 3);
330 *buf
= (__force __le16
)__raw_readw(addr
);
332 *buf
= (__force __le16
)__raw_readw(addr
+ 2);
342 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
344 #endif /* CONFIG_SSB_BLOCKIO */
346 static void ssb_pcmcia_write8(struct ssb_device
*dev
, u16 offset
, u8 value
)
348 struct ssb_bus
*bus
= dev
->bus
;
352 spin_lock_irqsave(&bus
->bar_lock
, flags
);
353 err
= select_core_and_segment(dev
, &offset
);
355 writeb(value
, bus
->mmio
+ offset
);
357 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
360 static void ssb_pcmcia_write16(struct ssb_device
*dev
, u16 offset
, u16 value
)
362 struct ssb_bus
*bus
= dev
->bus
;
366 spin_lock_irqsave(&bus
->bar_lock
, flags
);
367 err
= select_core_and_segment(dev
, &offset
);
369 writew(value
, bus
->mmio
+ offset
);
371 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
374 static void ssb_pcmcia_write32(struct ssb_device
*dev
, u16 offset
, u32 value
)
376 struct ssb_bus
*bus
= dev
->bus
;
380 spin_lock_irqsave(&bus
->bar_lock
, flags
);
381 err
= select_core_and_segment(dev
, &offset
);
383 writew((value
& 0x0000FFFF), bus
->mmio
+ offset
);
384 writew(((value
& 0xFFFF0000) >> 16), bus
->mmio
+ offset
+ 2);
387 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
390 #ifdef CONFIG_SSB_BLOCKIO
391 static void ssb_pcmcia_block_write(struct ssb_device
*dev
, const void *buffer
,
392 size_t count
, u16 offset
, u8 reg_width
)
394 struct ssb_bus
*bus
= dev
->bus
;
396 void __iomem
*addr
= bus
->mmio
+ offset
;
399 spin_lock_irqsave(&bus
->bar_lock
, flags
);
400 err
= select_core_and_segment(dev
, &offset
);
405 const u8
*buf
= buffer
;
408 __raw_writeb(*buf
, addr
);
415 const __le16
*buf
= buffer
;
417 SSB_WARN_ON(count
& 1);
419 __raw_writew((__force u16
)(*buf
), addr
);
426 const __le16
*buf
= buffer
;
428 SSB_WARN_ON(count
& 3);
430 __raw_writew((__force u16
)(*buf
), addr
);
432 __raw_writew((__force u16
)(*buf
), addr
+ 2);
443 spin_unlock_irqrestore(&bus
->bar_lock
, flags
);
445 #endif /* CONFIG_SSB_BLOCKIO */
447 /* Not "static", as it's used in main.c */
448 const struct ssb_bus_ops ssb_pcmcia_ops
= {
449 .read8
= ssb_pcmcia_read8
,
450 .read16
= ssb_pcmcia_read16
,
451 .read32
= ssb_pcmcia_read32
,
452 .write8
= ssb_pcmcia_write8
,
453 .write16
= ssb_pcmcia_write16
,
454 .write32
= ssb_pcmcia_write32
,
455 #ifdef CONFIG_SSB_BLOCKIO
456 .block_read
= ssb_pcmcia_block_read
,
457 .block_write
= ssb_pcmcia_block_write
,
461 static int ssb_pcmcia_sprom_command(struct ssb_bus
*bus
, u8 command
)
467 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROMCTL
, command
);
470 for (i
= 0; i
< 1000; i
++) {
471 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROMCTL
, &value
);
474 if (value
& SSB_PCMCIA_SPROMCTL_DONE
)
482 /* offset is the 16bit word offset */
483 static int ssb_pcmcia_sprom_read(struct ssb_bus
*bus
, u16 offset
, u16
*value
)
488 offset
*= 2; /* Make byte offset */
490 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRLO
,
494 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRHI
,
495 (offset
& 0xFF00) >> 8);
498 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_READ
);
501 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROM_DATALO
, &lo
);
504 err
= ssb_pcmcia_cfg_read(bus
, SSB_PCMCIA_SPROM_DATAHI
, &hi
);
507 *value
= (lo
| (((u16
)hi
) << 8));
512 /* offset is the 16bit word offset */
513 static int ssb_pcmcia_sprom_write(struct ssb_bus
*bus
, u16 offset
, u16 value
)
517 offset
*= 2; /* Make byte offset */
519 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRLO
,
523 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_ADDRHI
,
524 (offset
& 0xFF00) >> 8);
527 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_DATALO
,
531 err
= ssb_pcmcia_cfg_write(bus
, SSB_PCMCIA_SPROM_DATAHI
,
532 (value
& 0xFF00) >> 8);
535 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITE
);
543 /* Read the SPROM image. bufsize is in 16bit words. */
544 static int ssb_pcmcia_sprom_read_all(struct ssb_bus
*bus
, u16
*sprom
)
548 for (i
= 0; i
< SSB_PCMCIA_SPROM_SIZE
; i
++) {
549 err
= ssb_pcmcia_sprom_read(bus
, i
, &sprom
[i
]);
557 /* Write the SPROM image. size is in 16bit words. */
558 static int ssb_pcmcia_sprom_write_all(struct ssb_bus
*bus
, const u16
*sprom
)
562 size_t size
= SSB_PCMCIA_SPROM_SIZE
;
564 ssb_printk(KERN_NOTICE PFX
565 "Writing SPROM. Do NOT turn off the power! "
566 "Please stand by...\n");
567 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITEEN
);
569 ssb_printk(KERN_NOTICE PFX
570 "Could not enable SPROM write access.\n");
573 ssb_printk(KERN_NOTICE PFX
"[ 0%%");
575 for (i
= 0; i
< size
; i
++) {
578 else if (i
== size
/ 2)
580 else if (i
== (size
* 3) / 4)
584 err
= ssb_pcmcia_sprom_write(bus
, i
, sprom
[i
]);
586 ssb_printk(KERN_NOTICE PFX
587 "Failed to write to SPROM.\n");
592 err
= ssb_pcmcia_sprom_command(bus
, SSB_PCMCIA_SPROMCTL_WRITEDIS
);
594 ssb_printk(KERN_NOTICE PFX
595 "Could not disable SPROM write access.\n");
600 ssb_printk("100%% ]\n");
601 ssb_printk(KERN_NOTICE PFX
"SPROM written.\n");
604 return failed
? -EBUSY
: 0;
607 static int ssb_pcmcia_sprom_check_crc(const u16
*sprom
, size_t size
)
613 #define GOTO_ERROR_ON(condition, description) do { \
614 if (unlikely(condition)) { \
615 error_description = description; \
620 static int ssb_pcmcia_get_mac(struct pcmcia_device
*p_dev
,
624 struct ssb_sprom
*sprom
= priv
;
626 if (tuple
->TupleData
[0] != CISTPL_FUNCE_LAN_NODE_ID
)
628 if (tuple
->TupleDataLen
!= ETH_ALEN
+ 2)
630 if (tuple
->TupleData
[1] != ETH_ALEN
)
632 memcpy(sprom
->il0mac
, &tuple
->TupleData
[2], ETH_ALEN
);
636 static int ssb_pcmcia_do_get_invariants(struct pcmcia_device
*p_dev
,
640 struct ssb_init_invariants
*iv
= priv
;
641 struct ssb_sprom
*sprom
= &iv
->sprom
;
642 struct ssb_boardinfo
*bi
= &iv
->boardinfo
;
643 const char *error_description
;
645 GOTO_ERROR_ON(tuple
->TupleDataLen
< 1, "VEN tpl < 1");
646 switch (tuple
->TupleData
[0]) {
647 case SSB_PCMCIA_CIS_ID
:
648 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 5) &&
649 (tuple
->TupleDataLen
!= 7),
651 bi
->vendor
= tuple
->TupleData
[1] |
652 ((u16
)tuple
->TupleData
[2] << 8);
654 case SSB_PCMCIA_CIS_BOARDREV
:
655 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
656 "boardrev tpl size");
657 sprom
->board_rev
= tuple
->TupleData
[1];
659 case SSB_PCMCIA_CIS_PA
:
660 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 9) &&
661 (tuple
->TupleDataLen
!= 10),
663 sprom
->pa0b0
= tuple
->TupleData
[1] |
664 ((u16
)tuple
->TupleData
[2] << 8);
665 sprom
->pa0b1
= tuple
->TupleData
[3] |
666 ((u16
)tuple
->TupleData
[4] << 8);
667 sprom
->pa0b2
= tuple
->TupleData
[5] |
668 ((u16
)tuple
->TupleData
[6] << 8);
669 sprom
->itssi_a
= tuple
->TupleData
[7];
670 sprom
->itssi_bg
= tuple
->TupleData
[7];
671 sprom
->maxpwr_a
= tuple
->TupleData
[8];
672 sprom
->maxpwr_bg
= tuple
->TupleData
[8];
674 case SSB_PCMCIA_CIS_OEMNAME
:
675 /* We ignore this. */
677 case SSB_PCMCIA_CIS_CCODE
:
678 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
680 sprom
->country_code
= tuple
->TupleData
[1];
682 case SSB_PCMCIA_CIS_ANTENNA
:
683 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
685 sprom
->ant_available_a
= tuple
->TupleData
[1];
686 sprom
->ant_available_bg
= tuple
->TupleData
[1];
688 case SSB_PCMCIA_CIS_ANTGAIN
:
689 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 2,
691 sprom
->antenna_gain
.ghz24
.a0
= tuple
->TupleData
[1];
692 sprom
->antenna_gain
.ghz24
.a1
= tuple
->TupleData
[1];
693 sprom
->antenna_gain
.ghz24
.a2
= tuple
->TupleData
[1];
694 sprom
->antenna_gain
.ghz24
.a3
= tuple
->TupleData
[1];
695 sprom
->antenna_gain
.ghz5
.a0
= tuple
->TupleData
[1];
696 sprom
->antenna_gain
.ghz5
.a1
= tuple
->TupleData
[1];
697 sprom
->antenna_gain
.ghz5
.a2
= tuple
->TupleData
[1];
698 sprom
->antenna_gain
.ghz5
.a3
= tuple
->TupleData
[1];
700 case SSB_PCMCIA_CIS_BFLAGS
:
701 GOTO_ERROR_ON((tuple
->TupleDataLen
!= 3) &&
702 (tuple
->TupleDataLen
!= 5),
704 sprom
->boardflags_lo
= tuple
->TupleData
[1] |
705 ((u16
)tuple
->TupleData
[2] << 8);
707 case SSB_PCMCIA_CIS_LEDS
:
708 GOTO_ERROR_ON(tuple
->TupleDataLen
!= 5,
710 sprom
->gpio0
= tuple
->TupleData
[1];
711 sprom
->gpio1
= tuple
->TupleData
[2];
712 sprom
->gpio2
= tuple
->TupleData
[3];
713 sprom
->gpio3
= tuple
->TupleData
[4];
716 return -ENOSPC
; /* continue with next entry */
719 ssb_printk(KERN_ERR PFX
720 "PCMCIA: Failed to fetch device invariants: %s\n",
726 int ssb_pcmcia_get_invariants(struct ssb_bus
*bus
,
727 struct ssb_init_invariants
*iv
)
729 struct ssb_sprom
*sprom
= &iv
->sprom
;
732 memset(sprom
, 0xFF, sizeof(*sprom
));
734 sprom
->boardflags_lo
= 0;
735 sprom
->boardflags_hi
= 0;
737 /* First fetch the MAC address. */
738 res
= pcmcia_loop_tuple(bus
->host_pcmcia
, CISTPL_FUNCE
,
739 ssb_pcmcia_get_mac
, sprom
);
741 ssb_printk(KERN_ERR PFX
742 "PCMCIA: Failed to fetch MAC address\n");
746 /* Fetch the vendor specific tuples. */
747 res
= pcmcia_loop_tuple(bus
->host_pcmcia
, SSB_PCMCIA_CIS
,
748 ssb_pcmcia_do_get_invariants
, sprom
);
749 if ((res
== 0) || (res
== -ENOSPC
))
752 ssb_printk(KERN_ERR PFX
753 "PCMCIA: Failed to fetch device invariants\n");
757 static ssize_t
ssb_pcmcia_attr_sprom_show(struct device
*pcmciadev
,
758 struct device_attribute
*attr
,
761 struct pcmcia_device
*pdev
=
762 container_of(pcmciadev
, struct pcmcia_device
, dev
);
765 bus
= ssb_pcmcia_dev_to_bus(pdev
);
769 return ssb_attr_sprom_show(bus
, buf
,
770 ssb_pcmcia_sprom_read_all
);
773 static ssize_t
ssb_pcmcia_attr_sprom_store(struct device
*pcmciadev
,
774 struct device_attribute
*attr
,
775 const char *buf
, size_t count
)
777 struct pcmcia_device
*pdev
=
778 container_of(pcmciadev
, struct pcmcia_device
, dev
);
781 bus
= ssb_pcmcia_dev_to_bus(pdev
);
785 return ssb_attr_sprom_store(bus
, buf
, count
,
786 ssb_pcmcia_sprom_check_crc
,
787 ssb_pcmcia_sprom_write_all
);
790 static DEVICE_ATTR(ssb_sprom
, 0600,
791 ssb_pcmcia_attr_sprom_show
,
792 ssb_pcmcia_attr_sprom_store
);
794 static int ssb_pcmcia_cor_setup(struct ssb_bus
*bus
, u8 cor
)
799 err
= ssb_pcmcia_cfg_read(bus
, cor
, &val
);
802 val
&= ~COR_SOFT_RESET
;
803 val
|= COR_FUNC_ENA
| COR_IREQ_ENA
| COR_LEVEL_REQ
;
804 err
= ssb_pcmcia_cfg_write(bus
, cor
, val
);
812 /* Initialize the PCMCIA hardware. This is called on Init and Resume. */
813 int ssb_pcmcia_hardware_setup(struct ssb_bus
*bus
)
817 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
820 /* Switch segment to a known state and sync
821 * bus->mapped_pcmcia_seg with hardware state. */
822 ssb_pcmcia_switch_segment(bus
, 0);
823 /* Init the COR register. */
824 err
= ssb_pcmcia_cor_setup(bus
, CISREG_COR
);
827 /* Some cards also need this register to get poked. */
828 err
= ssb_pcmcia_cor_setup(bus
, CISREG_COR
+ 0x80);
835 void ssb_pcmcia_exit(struct ssb_bus
*bus
)
837 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
840 device_remove_file(&bus
->host_pcmcia
->dev
, &dev_attr_ssb_sprom
);
843 int ssb_pcmcia_init(struct ssb_bus
*bus
)
847 if (bus
->bustype
!= SSB_BUSTYPE_PCMCIA
)
850 err
= ssb_pcmcia_hardware_setup(bus
);
854 bus
->sprom_size
= SSB_PCMCIA_SPROM_SIZE
;
855 mutex_init(&bus
->sprom_mutex
);
856 err
= device_create_file(&bus
->host_pcmcia
->dev
, &dev_attr_ssb_sprom
);
862 ssb_printk(KERN_ERR PFX
"Failed to initialize PCMCIA host device\n");