1 /*
2  * linux/drivers/pcmcia/sa1100_neponset.c
3  *
4  * Neponset PCMCIA specific routines
5  */
6 #include <linux/kernel.h>
7 #include <linux/sched.h>
8 
9 #include <asm/hardware.h>
10 #include <asm/arch/assabet.h>
11 #include <asm/hardware/sa1111.h>
12 
13 #include "sa1100_generic.h"
14 #include "sa1111_generic.h"
15 
neponset_pcmcia_init(struct pcmcia_init * init)16 static int neponset_pcmcia_init(struct pcmcia_init *init)
17 {
18 	/* Set GPIO_A<3:0> to be outputs for PCMCIA/CF power controller: */
19 	PA_DDR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
20 
21 	/* MAX1600 to standby mode: */
22 	PA_DWR &= ~(GPIO_GPIO0 | GPIO_GPIO1 | GPIO_GPIO2 | GPIO_GPIO3);
23 	NCR_0 &= ~(NCR_A0VPP | NCR_A1VPP);
24 
25 	return sa1111_pcmcia_init(init);
26 }
27 
28 static int
neponset_pcmcia_configure_socket(const struct pcmcia_configure * conf)29 neponset_pcmcia_configure_socket(const struct pcmcia_configure *conf)
30 {
31 	unsigned int ncr_mask, pa_dwr_mask;
32 	unsigned int ncr_set, pa_dwr_set;
33 	int ret;
34 
35 	/* Neponset uses the Maxim MAX1600, with the following connections:
36 
37 	 *   MAX1600      Neponset
38 	 *
39 	 *    A0VCC        SA-1111 GPIO A<1>
40 	 *    A1VCC        SA-1111 GPIO A<0>
41 	 *    A0VPP        CPLD NCR A0VPP
42 	 *    A1VPP        CPLD NCR A1VPP
43 	 *    B0VCC        SA-1111 GPIO A<2>
44 	 *    B1VCC        SA-1111 GPIO A<3>
45 	 *    B0VPP        ground (slot B is CF)
46 	 *    B1VPP        ground (slot B is CF)
47 	 *
48 	 *     VX          VCC (5V)
49 	 *     VY          VCC3_3 (3.3V)
50 	 *     12INA       12V
51 	 *     12INB       ground (slot B is CF)
52 	 *
53 	 * The MAX1600 CODE pin is tied to ground, placing the device in
54 	 * "Standard Intel code" mode. Refer to the Maxim data sheet for
55 	 * the corresponding truth table.
56 	 */
57 
58 	switch (conf->sock) {
59 	case 0:
60 		pa_dwr_mask = GPIO_GPIO0 | GPIO_GPIO1;
61 		ncr_mask = NCR_A0VPP | NCR_A1VPP;
62 
63 		switch (conf->vcc) {
64 		default:
65 		case 0:		pa_dwr_set = 0;			break;
66 		case 33:	pa_dwr_set = GPIO_GPIO1;	break;
67 		case 50:	pa_dwr_set = GPIO_GPIO0;	break;
68 		}
69 
70 		switch (conf->vpp) {
71 		case 0:		ncr_set = 0;			break;
72 		case 120:	ncr_set = NCR_A1VPP;		break;
73 		default:
74 			if (conf->vpp == conf->vcc)
75 				ncr_set = NCR_A0VPP;
76 			else {
77 				printk(KERN_ERR "%s(): unrecognized VPP %u\n",
78 				       __FUNCTION__, conf->vpp);
79 				return -1;
80 			}
81 		}
82 		break;
83 
84 	case 1:
85 		pa_dwr_mask = GPIO_GPIO2 | GPIO_GPIO3;
86 		ncr_mask = 0;
87 		ncr_set = 0;
88 
89 		switch (conf->vcc) {
90 		default:
91 		case 0:		pa_dwr_set = 0;			break;
92 		case 33:	pa_dwr_set = GPIO_GPIO2;	break;
93 		case 50:	pa_dwr_set = GPIO_GPIO3;	break;
94 		}
95 
96 		if (conf->vpp != conf->vcc && conf->vpp != 0) {
97 			printk(KERN_ERR "%s(): CF slot cannot support VPP %u\n",
98 			       __FUNCTION__, conf->vpp);
99 			return -1;
100 		}
101 		break;
102 
103 	default:
104 		return -1;
105 	}
106 
107 	ret = sa1111_pcmcia_configure_socket(conf);
108 	if (ret == 0) {
109 		unsigned long flags;
110 
111 		local_irq_save(flags);
112 		NCR_0 = (NCR_0 & ~ncr_mask) | ncr_set;
113 		PA_DWR = (PA_DWR & ~pa_dwr_mask) | pa_dwr_set;
114 		local_irq_restore(flags);
115 	}
116 
117 	return 0;
118 }
119 
120 struct pcmcia_low_level neponset_pcmcia_ops = {
121 	init:			neponset_pcmcia_init,
122 	shutdown:		sa1111_pcmcia_shutdown,
123 	socket_state:		sa1111_pcmcia_socket_state,
124 	get_irq_info:		sa1111_pcmcia_get_irq_info,
125 	configure_socket:	neponset_pcmcia_configure_socket,
126 
127 	socket_init:		sa1111_pcmcia_socket_init,
128 	socket_suspend:		sa1111_pcmcia_socket_suspend,
129 };
130