1 /* SPDX-License-Identifier: GPL-2.0 */
2 #include <pcmcia/ss.h>
3 
4 struct module;
5 struct cpufreq_freqs;
6 
7 struct soc_pcmcia_regulator {
8 	struct regulator	*reg;
9 	bool			on;
10 };
11 
12 struct pcmcia_state {
13   unsigned detect: 1,
14             ready: 1,
15              bvd1: 1,
16              bvd2: 1,
17            wrprot: 1,
18             vs_3v: 1,
19             vs_Xv: 1;
20 };
21 
22 /*
23  * This structure encapsulates per-socket state which we might need to
24  * use when responding to a Card Services query of some kind.
25  */
26 struct soc_pcmcia_socket {
27 	struct pcmcia_socket	socket;
28 
29 	/*
30 	 * Info from low level handler
31 	 */
32 	unsigned int		nr;
33 	struct clk		*clk;
34 
35 	/*
36 	 * Core PCMCIA state
37 	 */
38 	const struct pcmcia_low_level *ops;
39 
40 	unsigned int		status;
41 	socket_state_t		cs_state;
42 
43 	unsigned short		spd_io[MAX_IO_WIN];
44 	unsigned short		spd_mem[MAX_WIN];
45 	unsigned short		spd_attr[MAX_WIN];
46 
47 	struct resource		res_skt;
48 	struct resource		res_io;
49 	struct resource		res_io_io;
50 	struct resource		res_mem;
51 	struct resource		res_attr;
52 
53 	struct {
54 		int		gpio;
55 		struct gpio_desc *desc;
56 		unsigned int	irq;
57 		const char	*name;
58 	} stat[6];
59 #define SOC_STAT_CD		0	/* Card detect */
60 #define SOC_STAT_BVD1		1	/* BATDEAD / IOSTSCHG */
61 #define SOC_STAT_BVD2		2	/* BATWARN / IOSPKR */
62 #define SOC_STAT_RDY		3	/* Ready / Interrupt */
63 #define SOC_STAT_VS1		4	/* Voltage sense 1 */
64 #define SOC_STAT_VS2		5	/* Voltage sense 2 */
65 
66 	struct gpio_desc	*gpio_reset;
67 	struct gpio_desc	*gpio_bus_enable;
68 	struct soc_pcmcia_regulator vcc;
69 	struct soc_pcmcia_regulator vpp;
70 
71 	unsigned int		irq_state;
72 
73 #ifdef CONFIG_CPU_FREQ
74 	struct notifier_block	cpufreq_nb;
75 #endif
76 	struct timer_list	poll_timer;
77 	struct list_head	node;
78 	void *driver_data;
79 };
80 
81 
82 struct pcmcia_low_level {
83 	struct module *owner;
84 
85 	/* first socket in system */
86 	int first;
87 	/* nr of sockets */
88 	int nr;
89 
90 	int (*hw_init)(struct soc_pcmcia_socket *);
91 	void (*hw_shutdown)(struct soc_pcmcia_socket *);
92 
93 	void (*socket_state)(struct soc_pcmcia_socket *, struct pcmcia_state *);
94 	int (*configure_socket)(struct soc_pcmcia_socket *, const socket_state_t *);
95 
96 	/*
97 	 * Enable card status IRQs on (re-)initialisation.  This can
98 	 * be called at initialisation, power management event, or
99 	 * pcmcia event.
100 	 */
101 	void (*socket_init)(struct soc_pcmcia_socket *);
102 
103 	/*
104 	 * Disable card status IRQs and PCMCIA bus on suspend.
105 	 */
106 	void (*socket_suspend)(struct soc_pcmcia_socket *);
107 
108 	/*
109 	 * Hardware specific timing routines.
110 	 * If provided, the get_timing routine overrides the SOC default.
111 	 */
112 	unsigned int (*get_timing)(struct soc_pcmcia_socket *, unsigned int, unsigned int);
113 	int (*set_timing)(struct soc_pcmcia_socket *);
114 	int (*show_timing)(struct soc_pcmcia_socket *, char *);
115 
116 #ifdef CONFIG_CPU_FREQ
117 	/*
118 	 * CPUFREQ support.
119 	 */
120 	int (*frequency_change)(struct soc_pcmcia_socket *, unsigned long, struct cpufreq_freqs *);
121 #endif
122 };
123 
124 
125 
126