xref: /openbmc/linux/drivers/pcmcia/soc_common.h (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * linux/drivers/pcmcia/soc_common.h
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 2000 John G Dorsey <john+@cs.cmu.edu>
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * This file contains definitions for the PCMCIA support code common to
81da177e4SLinus Torvalds  * integrated SOCs like the SA-11x0 and PXA2xx microprocessors.
91da177e4SLinus Torvalds  */
101da177e4SLinus Torvalds #ifndef _ASM_ARCH_PCMCIA
111da177e4SLinus Torvalds #define _ASM_ARCH_PCMCIA
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds /* include the world */
142a125dd5SEric Miao #include <linux/clk.h>
151da177e4SLinus Torvalds #include <linux/cpufreq.h>
161da177e4SLinus Torvalds #include <pcmcia/cistpl.h>
17*b83deaa7SArnd Bergmann #include <pcmcia/soc_common.h>
181da177e4SLinus Torvalds 
191da177e4SLinus Torvalds struct device;
2045ca7536SRussell King struct gpio_desc;
211da177e4SLinus Torvalds struct pcmcia_low_level;
22ac61b600SRussell King struct regulator;
23ac61b600SRussell King 
24b393c696SEric Miao struct skt_dev_info {
25b393c696SEric Miao 	int nskt;
26af741b0bSGustavo A. R. Silva 	struct soc_pcmcia_socket skt[];
27b393c696SEric Miao };
28b393c696SEric Miao 
291da177e4SLinus Torvalds struct soc_pcmcia_timing {
301da177e4SLinus Torvalds 	unsigned short io;
311da177e4SLinus Torvalds 	unsigned short mem;
321da177e4SLinus Torvalds 	unsigned short attr;
331da177e4SLinus Torvalds };
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds extern void soc_common_pcmcia_get_timing(struct soc_pcmcia_socket *, struct soc_pcmcia_timing *);
361da177e4SLinus Torvalds 
37e0d21178SRussell King void soc_pcmcia_init_one(struct soc_pcmcia_socket *skt,
38c8f9ce55SRussell King 	const struct pcmcia_low_level *ops, struct device *dev);
39097e296dSRussell King - ARM Linux void soc_pcmcia_remove_one(struct soc_pcmcia_socket *skt);
40097e296dSRussell King - ARM Linux int soc_pcmcia_add_one(struct soc_pcmcia_socket *skt);
4145ca7536SRussell King int soc_pcmcia_request_gpiods(struct soc_pcmcia_socket *skt);
421da177e4SLinus Torvalds 
43a1d05002SRussell King void soc_common_cf_socket_state(struct soc_pcmcia_socket *skt,
44a1d05002SRussell King 	struct pcmcia_state *state);
451da177e4SLinus Torvalds 
46ac61b600SRussell King int soc_pcmcia_regulator_set(struct soc_pcmcia_socket *skt,
47ac61b600SRussell King 	struct soc_pcmcia_regulator *r, int v);
48ac61b600SRussell King 
497d16b658SDominik Brodowski #ifdef CONFIG_PCMCIA_DEBUG
501da177e4SLinus Torvalds 
511da177e4SLinus Torvalds extern void soc_pcmcia_debug(struct soc_pcmcia_socket *skt, const char *func,
521da177e4SLinus Torvalds 			     int lvl, const char *fmt, ...);
531da177e4SLinus Torvalds 
541da177e4SLinus Torvalds #define debug(skt, lvl, fmt, arg...) \
551da177e4SLinus Torvalds 	soc_pcmcia_debug(skt, __func__, lvl, fmt , ## arg)
561da177e4SLinus Torvalds 
571da177e4SLinus Torvalds #else
581da177e4SLinus Torvalds #define debug(skt, lvl, fmt, arg...) do { } while (0)
591da177e4SLinus Torvalds #endif
601da177e4SLinus Torvalds 
611da177e4SLinus Torvalds 
621da177e4SLinus Torvalds /*
631da177e4SLinus Torvalds  * The PC Card Standard, Release 7, section 4.13.4, says that twIORD
641da177e4SLinus Torvalds  * has a minimum value of 165ns. Section 4.13.5 says that twIOWR has
651da177e4SLinus Torvalds  * a minimum value of 165ns, as well. Section 4.7.2 (describing
661da177e4SLinus Torvalds  * common and attribute memory write timing) says that twWE has a
671da177e4SLinus Torvalds  * minimum value of 150ns for a 250ns cycle time (for 5V operation;
681da177e4SLinus Torvalds  * see section 4.7.4), or 300ns for a 600ns cycle time (for 3.3V
691da177e4SLinus Torvalds  * operation, also section 4.7.4). Section 4.7.3 says that taOE
701da177e4SLinus Torvalds  * has a maximum value of 150ns for a 300ns cycle time (for 5V
711da177e4SLinus Torvalds  * operation), or 300ns for a 600ns cycle time (for 3.3V operation).
721da177e4SLinus Torvalds  *
731da177e4SLinus Torvalds  * When configuring memory maps, Card Services appears to adopt the policy
741da177e4SLinus Torvalds  * that a memory access time of "0" means "use the default." The default
751da177e4SLinus Torvalds  * PCMCIA I/O command width time is 165ns. The default PCMCIA 5V attribute
761da177e4SLinus Torvalds  * and memory command width time is 150ns; the PCMCIA 3.3V attribute and
771da177e4SLinus Torvalds  * memory command width time is 300ns.
781da177e4SLinus Torvalds  */
791da177e4SLinus Torvalds #define SOC_PCMCIA_IO_ACCESS		(165)
801da177e4SLinus Torvalds #define SOC_PCMCIA_5V_MEM_ACCESS	(150)
811da177e4SLinus Torvalds #define SOC_PCMCIA_3V_MEM_ACCESS	(300)
821da177e4SLinus Torvalds #define SOC_PCMCIA_ATTR_MEM_ACCESS	(300)
831da177e4SLinus Torvalds 
841da177e4SLinus Torvalds /*
851da177e4SLinus Torvalds  * The socket driver actually works nicely in interrupt-driven form,
861da177e4SLinus Torvalds  * so the (relatively infrequent) polling is "just to be sure."
871da177e4SLinus Torvalds  */
881da177e4SLinus Torvalds #define SOC_PCMCIA_POLL_PERIOD    (2*HZ)
891da177e4SLinus Torvalds 
901da177e4SLinus Torvalds 
911da177e4SLinus Torvalds /* I/O pins replacing memory pins
921da177e4SLinus Torvalds  * (PCMCIA System Architecture, 2nd ed., by Don Anderson, p.75)
931da177e4SLinus Torvalds  *
941da177e4SLinus Torvalds  * These signals change meaning when going from memory-only to
951da177e4SLinus Torvalds  * memory-or-I/O interface:
961da177e4SLinus Torvalds  */
971da177e4SLinus Torvalds #define iostschg bvd1
981da177e4SLinus Torvalds #define iospkr   bvd2
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds #endif
101