xref: /openbmc/linux/arch/powerpc/platforms/8xx/cpm1.c (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
14128a89aSChristophe Leroy // SPDX-License-Identifier: GPL-2.0
24128a89aSChristophe Leroy /*
34128a89aSChristophe Leroy  * General Purpose functions for the global management of the
44128a89aSChristophe Leroy  * Communication Processor Module.
54128a89aSChristophe Leroy  * Copyright (c) 1997 Dan error_act (dmalek@jlc.net)
64128a89aSChristophe Leroy  *
74128a89aSChristophe Leroy  * In addition to the individual control of the communication
84128a89aSChristophe Leroy  * channels, there are a few functions that globally affect the
94128a89aSChristophe Leroy  * communication processor.
104128a89aSChristophe Leroy  *
114128a89aSChristophe Leroy  * Buffer descriptors must be allocated from the dual ported memory
124128a89aSChristophe Leroy  * space.  The allocator for that is here.  When the communication
134128a89aSChristophe Leroy  * process is reset, we reclaim the memory available.  There is
144128a89aSChristophe Leroy  * currently no deallocator for this memory.
154128a89aSChristophe Leroy  * The amount of space available is platform dependent.  On the
164128a89aSChristophe Leroy  * MBX, the EPPC software loads additional microcode into the
174128a89aSChristophe Leroy  * communication processor, and uses some of the DP ram for this
184128a89aSChristophe Leroy  * purpose.  Current, the first 512 bytes and the last 256 bytes of
194128a89aSChristophe Leroy  * memory are used.  Right now I am conservative and only use the
204128a89aSChristophe Leroy  * memory that can never be used for microcode.  If there are
214128a89aSChristophe Leroy  * applications that require more DP ram, we can expand the boundaries
224128a89aSChristophe Leroy  * but then we have to be careful of any downloaded microcode.
234128a89aSChristophe Leroy  */
244128a89aSChristophe Leroy #include <linux/errno.h>
254128a89aSChristophe Leroy #include <linux/sched.h>
264128a89aSChristophe Leroy #include <linux/kernel.h>
274128a89aSChristophe Leroy #include <linux/dma-mapping.h>
284128a89aSChristophe Leroy #include <linux/param.h>
294128a89aSChristophe Leroy #include <linux/string.h>
304128a89aSChristophe Leroy #include <linux/mm.h>
314128a89aSChristophe Leroy #include <linux/interrupt.h>
324128a89aSChristophe Leroy #include <linux/irq.h>
334128a89aSChristophe Leroy #include <linux/module.h>
344128a89aSChristophe Leroy #include <linux/spinlock.h>
354128a89aSChristophe Leroy #include <linux/slab.h>
36e6f6390aSChristophe Leroy #include <linux/of_irq.h>
374128a89aSChristophe Leroy #include <asm/page.h>
384128a89aSChristophe Leroy #include <asm/8xx_immap.h>
394128a89aSChristophe Leroy #include <asm/cpm1.h>
404128a89aSChristophe Leroy #include <asm/io.h>
414128a89aSChristophe Leroy #include <asm/rheap.h>
424128a89aSChristophe Leroy #include <asm/cpm.h>
434128a89aSChristophe Leroy 
44*fbbf4280SChristophe Leroy #include <sysdev/fsl_soc.h>
454128a89aSChristophe Leroy 
464128a89aSChristophe Leroy #ifdef CONFIG_8xx_GPIO
47a99cc668SArnd Bergmann #include <linux/gpio/legacy-of-mm-gpiochip.h>
484128a89aSChristophe Leroy #endif
494128a89aSChristophe Leroy 
504128a89aSChristophe Leroy #define CPM_MAP_SIZE    (0x4000)
514128a89aSChristophe Leroy 
524128a89aSChristophe Leroy cpm8xx_t __iomem *cpmp;  /* Pointer to comm processor space */
53eafd687eSChristophe Leroy immap_t __iomem *mpc8xx_immr = (void __iomem *)VIRT_IMMR_BASE;
544128a89aSChristophe Leroy 
cpm_reset(void)554128a89aSChristophe Leroy void __init cpm_reset(void)
564128a89aSChristophe Leroy {
574128a89aSChristophe Leroy 	cpmp = &mpc8xx_immr->im_cpm;
584128a89aSChristophe Leroy 
594128a89aSChristophe Leroy #ifndef CONFIG_PPC_EARLY_DEBUG_CPM
604128a89aSChristophe Leroy 	/* Perform a reset. */
614128a89aSChristophe Leroy 	out_be16(&cpmp->cp_cpcr, CPM_CR_RST | CPM_CR_FLG);
624128a89aSChristophe Leroy 
634128a89aSChristophe Leroy 	/* Wait for it. */
644128a89aSChristophe Leroy 	while (in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG);
654128a89aSChristophe Leroy #endif
664128a89aSChristophe Leroy 
674128a89aSChristophe Leroy #ifdef CONFIG_UCODE_PATCH
684128a89aSChristophe Leroy 	cpm_load_patch(cpmp);
694128a89aSChristophe Leroy #endif
704128a89aSChristophe Leroy 
714128a89aSChristophe Leroy 	/*
724128a89aSChristophe Leroy 	 * Set SDMA Bus Request priority 5.
734128a89aSChristophe Leroy 	 * On 860T, this also enables FEC priority 6.  I am not sure
744128a89aSChristophe Leroy 	 * this is what we really want for some applications, but the
754128a89aSChristophe Leroy 	 * manual recommends it.
764128a89aSChristophe Leroy 	 * Bit 25, FAM can also be set to use FEC aggressive mode (860T).
774128a89aSChristophe Leroy 	 */
784128a89aSChristophe Leroy 	if ((mfspr(SPRN_IMMR) & 0xffff) == 0x0900) /* MPC885 */
79*fbbf4280SChristophe Leroy 		out_be32(&mpc8xx_immr->im_siu_conf.sc_sdcr, 0x40);
804128a89aSChristophe Leroy 	else
81*fbbf4280SChristophe Leroy 		out_be32(&mpc8xx_immr->im_siu_conf.sc_sdcr, 1);
824128a89aSChristophe Leroy }
834128a89aSChristophe Leroy 
844128a89aSChristophe Leroy static DEFINE_SPINLOCK(cmd_lock);
854128a89aSChristophe Leroy 
864128a89aSChristophe Leroy #define MAX_CR_CMD_LOOPS        10000
874128a89aSChristophe Leroy 
cpm_command(u32 command,u8 opcode)884128a89aSChristophe Leroy int cpm_command(u32 command, u8 opcode)
894128a89aSChristophe Leroy {
904128a89aSChristophe Leroy 	int i, ret;
914128a89aSChristophe Leroy 	unsigned long flags;
924128a89aSChristophe Leroy 
93b38736acSHerve Codina 	if (command & 0xffffff03)
944128a89aSChristophe Leroy 		return -EINVAL;
954128a89aSChristophe Leroy 
964128a89aSChristophe Leroy 	spin_lock_irqsave(&cmd_lock, flags);
974128a89aSChristophe Leroy 
984128a89aSChristophe Leroy 	ret = 0;
994128a89aSChristophe Leroy 	out_be16(&cpmp->cp_cpcr, command | CPM_CR_FLG | (opcode << 8));
1004128a89aSChristophe Leroy 	for (i = 0; i < MAX_CR_CMD_LOOPS; i++)
1014128a89aSChristophe Leroy 		if ((in_be16(&cpmp->cp_cpcr) & CPM_CR_FLG) == 0)
1024128a89aSChristophe Leroy 			goto out;
1034128a89aSChristophe Leroy 
1044128a89aSChristophe Leroy 	printk(KERN_ERR "%s(): Not able to issue CPM command\n", __func__);
1054128a89aSChristophe Leroy 	ret = -EIO;
1064128a89aSChristophe Leroy out:
1074128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cmd_lock, flags);
1084128a89aSChristophe Leroy 	return ret;
1094128a89aSChristophe Leroy }
1104128a89aSChristophe Leroy EXPORT_SYMBOL(cpm_command);
1114128a89aSChristophe Leroy 
1124128a89aSChristophe Leroy /*
1134128a89aSChristophe Leroy  * Set a baud rate generator.  This needs lots of work.  There are
1144128a89aSChristophe Leroy  * four BRGs, any of which can be wired to any channel.
1154128a89aSChristophe Leroy  * The internal baud rate clock is the system clock divided by 16.
1164128a89aSChristophe Leroy  * This assumes the baudrate is 16x oversampled by the uart.
1174128a89aSChristophe Leroy  */
1184128a89aSChristophe Leroy #define BRG_INT_CLK		(get_brgfreq())
1194128a89aSChristophe Leroy #define BRG_UART_CLK		(BRG_INT_CLK/16)
1204128a89aSChristophe Leroy #define BRG_UART_CLK_DIV16	(BRG_UART_CLK/16)
1214128a89aSChristophe Leroy 
1224128a89aSChristophe Leroy void
cpm_setbrg(uint brg,uint rate)1234128a89aSChristophe Leroy cpm_setbrg(uint brg, uint rate)
1244128a89aSChristophe Leroy {
1254128a89aSChristophe Leroy 	u32 __iomem *bp;
1264128a89aSChristophe Leroy 
1274128a89aSChristophe Leroy 	/* This is good enough to get SMCs running..... */
1284128a89aSChristophe Leroy 	bp = &cpmp->cp_brgc1;
1294128a89aSChristophe Leroy 	bp += brg;
1304128a89aSChristophe Leroy 	/*
1314128a89aSChristophe Leroy 	 * The BRG has a 12-bit counter.  For really slow baud rates (or
1324128a89aSChristophe Leroy 	 * really fast processors), we may have to further divide by 16.
1334128a89aSChristophe Leroy 	 */
1344128a89aSChristophe Leroy 	if (((BRG_UART_CLK / rate) - 1) < 4096)
1354128a89aSChristophe Leroy 		out_be32(bp, (((BRG_UART_CLK / rate) - 1) << 1) | CPM_BRG_EN);
1364128a89aSChristophe Leroy 	else
1374128a89aSChristophe Leroy 		out_be32(bp, (((BRG_UART_CLK_DIV16 / rate) - 1) << 1) |
1384128a89aSChristophe Leroy 			      CPM_BRG_EN | CPM_BRG_DIV16);
1394128a89aSChristophe Leroy }
14022f8e625SRandy Dunlap EXPORT_SYMBOL(cpm_setbrg);
1414128a89aSChristophe Leroy 
1424128a89aSChristophe Leroy struct cpm_ioport16 {
1434128a89aSChristophe Leroy 	__be16 dir, par, odr_sor, dat, intr;
1444128a89aSChristophe Leroy 	__be16 res[3];
1454128a89aSChristophe Leroy };
1464128a89aSChristophe Leroy 
1474128a89aSChristophe Leroy struct cpm_ioport32b {
1484128a89aSChristophe Leroy 	__be32 dir, par, odr, dat;
1494128a89aSChristophe Leroy };
1504128a89aSChristophe Leroy 
1514128a89aSChristophe Leroy struct cpm_ioport32e {
1524128a89aSChristophe Leroy 	__be32 dir, par, sor, odr, dat;
1534128a89aSChristophe Leroy };
1544128a89aSChristophe Leroy 
cpm1_set_pin32(int port,int pin,int flags)155132f92fdSChristophe Leroy static void __init cpm1_set_pin32(int port, int pin, int flags)
1564128a89aSChristophe Leroy {
1574128a89aSChristophe Leroy 	struct cpm_ioport32e __iomem *iop;
1584128a89aSChristophe Leroy 	pin = 1 << (31 - pin);
1594128a89aSChristophe Leroy 
1604128a89aSChristophe Leroy 	if (port == CPM_PORTB)
1614128a89aSChristophe Leroy 		iop = (struct cpm_ioport32e __iomem *)
1624128a89aSChristophe Leroy 		      &mpc8xx_immr->im_cpm.cp_pbdir;
1634128a89aSChristophe Leroy 	else
1644128a89aSChristophe Leroy 		iop = (struct cpm_ioport32e __iomem *)
1654128a89aSChristophe Leroy 		      &mpc8xx_immr->im_cpm.cp_pedir;
1664128a89aSChristophe Leroy 
1674128a89aSChristophe Leroy 	if (flags & CPM_PIN_OUTPUT)
1684128a89aSChristophe Leroy 		setbits32(&iop->dir, pin);
1694128a89aSChristophe Leroy 	else
1704128a89aSChristophe Leroy 		clrbits32(&iop->dir, pin);
1714128a89aSChristophe Leroy 
1724128a89aSChristophe Leroy 	if (!(flags & CPM_PIN_GPIO))
1734128a89aSChristophe Leroy 		setbits32(&iop->par, pin);
1744128a89aSChristophe Leroy 	else
1754128a89aSChristophe Leroy 		clrbits32(&iop->par, pin);
1764128a89aSChristophe Leroy 
1774128a89aSChristophe Leroy 	if (port == CPM_PORTB) {
1784128a89aSChristophe Leroy 		if (flags & CPM_PIN_OPENDRAIN)
1794128a89aSChristophe Leroy 			setbits16(&mpc8xx_immr->im_cpm.cp_pbodr, pin);
1804128a89aSChristophe Leroy 		else
1814128a89aSChristophe Leroy 			clrbits16(&mpc8xx_immr->im_cpm.cp_pbodr, pin);
1824128a89aSChristophe Leroy 	}
1834128a89aSChristophe Leroy 
1844128a89aSChristophe Leroy 	if (port == CPM_PORTE) {
1854128a89aSChristophe Leroy 		if (flags & CPM_PIN_SECONDARY)
1864128a89aSChristophe Leroy 			setbits32(&iop->sor, pin);
1874128a89aSChristophe Leroy 		else
1884128a89aSChristophe Leroy 			clrbits32(&iop->sor, pin);
1894128a89aSChristophe Leroy 
1904128a89aSChristophe Leroy 		if (flags & CPM_PIN_OPENDRAIN)
1914128a89aSChristophe Leroy 			setbits32(&mpc8xx_immr->im_cpm.cp_peodr, pin);
1924128a89aSChristophe Leroy 		else
1934128a89aSChristophe Leroy 			clrbits32(&mpc8xx_immr->im_cpm.cp_peodr, pin);
1944128a89aSChristophe Leroy 	}
1954128a89aSChristophe Leroy }
1964128a89aSChristophe Leroy 
cpm1_set_pin16(int port,int pin,int flags)197132f92fdSChristophe Leroy static void __init cpm1_set_pin16(int port, int pin, int flags)
1984128a89aSChristophe Leroy {
1994128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop =
2004128a89aSChristophe Leroy 		(struct cpm_ioport16 __iomem *)&mpc8xx_immr->im_ioport;
2014128a89aSChristophe Leroy 
2024128a89aSChristophe Leroy 	pin = 1 << (15 - pin);
2034128a89aSChristophe Leroy 
2044128a89aSChristophe Leroy 	if (port != 0)
2054128a89aSChristophe Leroy 		iop += port - 1;
2064128a89aSChristophe Leroy 
2074128a89aSChristophe Leroy 	if (flags & CPM_PIN_OUTPUT)
2084128a89aSChristophe Leroy 		setbits16(&iop->dir, pin);
2094128a89aSChristophe Leroy 	else
2104128a89aSChristophe Leroy 		clrbits16(&iop->dir, pin);
2114128a89aSChristophe Leroy 
2124128a89aSChristophe Leroy 	if (!(flags & CPM_PIN_GPIO))
2134128a89aSChristophe Leroy 		setbits16(&iop->par, pin);
2144128a89aSChristophe Leroy 	else
2154128a89aSChristophe Leroy 		clrbits16(&iop->par, pin);
2164128a89aSChristophe Leroy 
2174128a89aSChristophe Leroy 	if (port == CPM_PORTA) {
2184128a89aSChristophe Leroy 		if (flags & CPM_PIN_OPENDRAIN)
2194128a89aSChristophe Leroy 			setbits16(&iop->odr_sor, pin);
2204128a89aSChristophe Leroy 		else
2214128a89aSChristophe Leroy 			clrbits16(&iop->odr_sor, pin);
2224128a89aSChristophe Leroy 	}
2234128a89aSChristophe Leroy 	if (port == CPM_PORTC) {
2244128a89aSChristophe Leroy 		if (flags & CPM_PIN_SECONDARY)
2254128a89aSChristophe Leroy 			setbits16(&iop->odr_sor, pin);
2264128a89aSChristophe Leroy 		else
2274128a89aSChristophe Leroy 			clrbits16(&iop->odr_sor, pin);
2284128a89aSChristophe Leroy 		if (flags & CPM_PIN_FALLEDGE)
2294128a89aSChristophe Leroy 			setbits16(&iop->intr, pin);
2304128a89aSChristophe Leroy 		else
2314128a89aSChristophe Leroy 			clrbits16(&iop->intr, pin);
2324128a89aSChristophe Leroy 	}
2334128a89aSChristophe Leroy }
2344128a89aSChristophe Leroy 
cpm1_set_pin(enum cpm_port port,int pin,int flags)235132f92fdSChristophe Leroy void __init cpm1_set_pin(enum cpm_port port, int pin, int flags)
2364128a89aSChristophe Leroy {
2374128a89aSChristophe Leroy 	if (port == CPM_PORTB || port == CPM_PORTE)
2384128a89aSChristophe Leroy 		cpm1_set_pin32(port, pin, flags);
2394128a89aSChristophe Leroy 	else
2404128a89aSChristophe Leroy 		cpm1_set_pin16(port, pin, flags);
2414128a89aSChristophe Leroy }
2424128a89aSChristophe Leroy 
cpm1_clk_setup(enum cpm_clk_target target,int clock,int mode)243132f92fdSChristophe Leroy int __init cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode)
2444128a89aSChristophe Leroy {
2454128a89aSChristophe Leroy 	int shift;
2464128a89aSChristophe Leroy 	int i, bits = 0;
2474128a89aSChristophe Leroy 	u32 __iomem *reg;
2484128a89aSChristophe Leroy 	u32 mask = 7;
2494128a89aSChristophe Leroy 
2504128a89aSChristophe Leroy 	u8 clk_map[][3] = {
2514128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_BRG1, 0},
2524128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_BRG2, 1},
2534128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_BRG3, 2},
2544128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_BRG4, 3},
2554128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_CLK1, 4},
2564128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_CLK2, 5},
2574128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_CLK3, 6},
2584128a89aSChristophe Leroy 		{CPM_CLK_SCC1, CPM_CLK4, 7},
2594128a89aSChristophe Leroy 
2604128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_BRG1, 0},
2614128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_BRG2, 1},
2624128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_BRG3, 2},
2634128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_BRG4, 3},
2644128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_CLK1, 4},
2654128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_CLK2, 5},
2664128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_CLK3, 6},
2674128a89aSChristophe Leroy 		{CPM_CLK_SCC2, CPM_CLK4, 7},
2684128a89aSChristophe Leroy 
2694128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_BRG1, 0},
2704128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_BRG2, 1},
2714128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_BRG3, 2},
2724128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_BRG4, 3},
2734128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_CLK5, 4},
2744128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_CLK6, 5},
2754128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_CLK7, 6},
2764128a89aSChristophe Leroy 		{CPM_CLK_SCC3, CPM_CLK8, 7},
2774128a89aSChristophe Leroy 
2784128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_BRG1, 0},
2794128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_BRG2, 1},
2804128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_BRG3, 2},
2814128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_BRG4, 3},
2824128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_CLK5, 4},
2834128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_CLK6, 5},
2844128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_CLK7, 6},
2854128a89aSChristophe Leroy 		{CPM_CLK_SCC4, CPM_CLK8, 7},
2864128a89aSChristophe Leroy 
2874128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_BRG1, 0},
2884128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_BRG2, 1},
2894128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_BRG3, 2},
2904128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_BRG4, 3},
2914128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_CLK1, 4},
2924128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_CLK2, 5},
2934128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_CLK3, 6},
2944128a89aSChristophe Leroy 		{CPM_CLK_SMC1, CPM_CLK4, 7},
2954128a89aSChristophe Leroy 
2964128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_BRG1, 0},
2974128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_BRG2, 1},
2984128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_BRG3, 2},
2994128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_BRG4, 3},
3004128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_CLK5, 4},
3014128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_CLK6, 5},
3024128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_CLK7, 6},
3034128a89aSChristophe Leroy 		{CPM_CLK_SMC2, CPM_CLK8, 7},
3044128a89aSChristophe Leroy 	};
3054128a89aSChristophe Leroy 
3064128a89aSChristophe Leroy 	switch (target) {
3074128a89aSChristophe Leroy 	case CPM_CLK_SCC1:
3084128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_sicr;
3094128a89aSChristophe Leroy 		shift = 0;
3104128a89aSChristophe Leroy 		break;
3114128a89aSChristophe Leroy 
3124128a89aSChristophe Leroy 	case CPM_CLK_SCC2:
3134128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_sicr;
3144128a89aSChristophe Leroy 		shift = 8;
3154128a89aSChristophe Leroy 		break;
3164128a89aSChristophe Leroy 
3174128a89aSChristophe Leroy 	case CPM_CLK_SCC3:
3184128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_sicr;
3194128a89aSChristophe Leroy 		shift = 16;
3204128a89aSChristophe Leroy 		break;
3214128a89aSChristophe Leroy 
3224128a89aSChristophe Leroy 	case CPM_CLK_SCC4:
3234128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_sicr;
3244128a89aSChristophe Leroy 		shift = 24;
3254128a89aSChristophe Leroy 		break;
3264128a89aSChristophe Leroy 
3274128a89aSChristophe Leroy 	case CPM_CLK_SMC1:
3284128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_simode;
3294128a89aSChristophe Leroy 		shift = 12;
3304128a89aSChristophe Leroy 		break;
3314128a89aSChristophe Leroy 
3324128a89aSChristophe Leroy 	case CPM_CLK_SMC2:
3334128a89aSChristophe Leroy 		reg = &mpc8xx_immr->im_cpm.cp_simode;
3344128a89aSChristophe Leroy 		shift = 28;
3354128a89aSChristophe Leroy 		break;
3364128a89aSChristophe Leroy 
3374128a89aSChristophe Leroy 	default:
3384128a89aSChristophe Leroy 		printk(KERN_ERR "cpm1_clock_setup: invalid clock target\n");
3394128a89aSChristophe Leroy 		return -EINVAL;
3404128a89aSChristophe Leroy 	}
3414128a89aSChristophe Leroy 
3424128a89aSChristophe Leroy 	for (i = 0; i < ARRAY_SIZE(clk_map); i++) {
3434128a89aSChristophe Leroy 		if (clk_map[i][0] == target && clk_map[i][1] == clock) {
3444128a89aSChristophe Leroy 			bits = clk_map[i][2];
3454128a89aSChristophe Leroy 			break;
3464128a89aSChristophe Leroy 		}
3474128a89aSChristophe Leroy 	}
3484128a89aSChristophe Leroy 
3494128a89aSChristophe Leroy 	if (i == ARRAY_SIZE(clk_map)) {
3504128a89aSChristophe Leroy 		printk(KERN_ERR "cpm1_clock_setup: invalid clock combination\n");
3514128a89aSChristophe Leroy 		return -EINVAL;
3524128a89aSChristophe Leroy 	}
3534128a89aSChristophe Leroy 
3544128a89aSChristophe Leroy 	bits <<= shift;
3554128a89aSChristophe Leroy 	mask <<= shift;
3564128a89aSChristophe Leroy 
3574128a89aSChristophe Leroy 	if (reg == &mpc8xx_immr->im_cpm.cp_sicr) {
3584128a89aSChristophe Leroy 		if (mode == CPM_CLK_RTX) {
3594128a89aSChristophe Leroy 			bits |= bits << 3;
3604128a89aSChristophe Leroy 			mask |= mask << 3;
3614128a89aSChristophe Leroy 		} else if (mode == CPM_CLK_RX) {
3624128a89aSChristophe Leroy 			bits <<= 3;
3634128a89aSChristophe Leroy 			mask <<= 3;
3644128a89aSChristophe Leroy 		}
3654128a89aSChristophe Leroy 	}
3664128a89aSChristophe Leroy 
3674128a89aSChristophe Leroy 	out_be32(reg, (in_be32(reg) & ~mask) | bits);
3684128a89aSChristophe Leroy 
3694128a89aSChristophe Leroy 	return 0;
3704128a89aSChristophe Leroy }
3714128a89aSChristophe Leroy 
3724128a89aSChristophe Leroy /*
3734128a89aSChristophe Leroy  * GPIO LIB API implementation
3744128a89aSChristophe Leroy  */
3754128a89aSChristophe Leroy #ifdef CONFIG_8xx_GPIO
3764128a89aSChristophe Leroy 
3774128a89aSChristophe Leroy struct cpm1_gpio16_chip {
3784128a89aSChristophe Leroy 	struct of_mm_gpio_chip mm_gc;
3794128a89aSChristophe Leroy 	spinlock_t lock;
3804128a89aSChristophe Leroy 
3814128a89aSChristophe Leroy 	/* shadowed data register to clear/set bits safely */
3824128a89aSChristophe Leroy 	u16 cpdata;
3834128a89aSChristophe Leroy 
3844128a89aSChristophe Leroy 	/* IRQ associated with Pins when relevant */
3854128a89aSChristophe Leroy 	int irq[16];
3864128a89aSChristophe Leroy };
3874128a89aSChristophe Leroy 
cpm1_gpio16_save_regs(struct of_mm_gpio_chip * mm_gc)3884128a89aSChristophe Leroy static void cpm1_gpio16_save_regs(struct of_mm_gpio_chip *mm_gc)
3894128a89aSChristophe Leroy {
3904128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc =
3914128a89aSChristophe Leroy 		container_of(mm_gc, struct cpm1_gpio16_chip, mm_gc);
3924128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop = mm_gc->regs;
3934128a89aSChristophe Leroy 
3944128a89aSChristophe Leroy 	cpm1_gc->cpdata = in_be16(&iop->dat);
3954128a89aSChristophe Leroy }
3964128a89aSChristophe Leroy 
cpm1_gpio16_get(struct gpio_chip * gc,unsigned int gpio)3974128a89aSChristophe Leroy static int cpm1_gpio16_get(struct gpio_chip *gc, unsigned int gpio)
3984128a89aSChristophe Leroy {
3994128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
4004128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop = mm_gc->regs;
4014128a89aSChristophe Leroy 	u16 pin_mask;
4024128a89aSChristophe Leroy 
4034128a89aSChristophe Leroy 	pin_mask = 1 << (15 - gpio);
4044128a89aSChristophe Leroy 
4054128a89aSChristophe Leroy 	return !!(in_be16(&iop->dat) & pin_mask);
4064128a89aSChristophe Leroy }
4074128a89aSChristophe Leroy 
__cpm1_gpio16_set(struct of_mm_gpio_chip * mm_gc,u16 pin_mask,int value)4084128a89aSChristophe Leroy static void __cpm1_gpio16_set(struct of_mm_gpio_chip *mm_gc, u16 pin_mask,
4094128a89aSChristophe Leroy 	int value)
4104128a89aSChristophe Leroy {
4114128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
4124128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop = mm_gc->regs;
4134128a89aSChristophe Leroy 
4144128a89aSChristophe Leroy 	if (value)
4154128a89aSChristophe Leroy 		cpm1_gc->cpdata |= pin_mask;
4164128a89aSChristophe Leroy 	else
4174128a89aSChristophe Leroy 		cpm1_gc->cpdata &= ~pin_mask;
4184128a89aSChristophe Leroy 
4194128a89aSChristophe Leroy 	out_be16(&iop->dat, cpm1_gc->cpdata);
4204128a89aSChristophe Leroy }
4214128a89aSChristophe Leroy 
cpm1_gpio16_set(struct gpio_chip * gc,unsigned int gpio,int value)4224128a89aSChristophe Leroy static void cpm1_gpio16_set(struct gpio_chip *gc, unsigned int gpio, int value)
4234128a89aSChristophe Leroy {
4244128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
4254128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
4264128a89aSChristophe Leroy 	unsigned long flags;
4274128a89aSChristophe Leroy 	u16 pin_mask = 1 << (15 - gpio);
4284128a89aSChristophe Leroy 
4294128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
4304128a89aSChristophe Leroy 
4314128a89aSChristophe Leroy 	__cpm1_gpio16_set(mm_gc, pin_mask, value);
4324128a89aSChristophe Leroy 
4334128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
4344128a89aSChristophe Leroy }
4354128a89aSChristophe Leroy 
cpm1_gpio16_to_irq(struct gpio_chip * gc,unsigned int gpio)4364128a89aSChristophe Leroy static int cpm1_gpio16_to_irq(struct gpio_chip *gc, unsigned int gpio)
4374128a89aSChristophe Leroy {
4384128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
4394128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
4404128a89aSChristophe Leroy 
4414128a89aSChristophe Leroy 	return cpm1_gc->irq[gpio] ? : -ENXIO;
4424128a89aSChristophe Leroy }
4434128a89aSChristophe Leroy 
cpm1_gpio16_dir_out(struct gpio_chip * gc,unsigned int gpio,int val)4444128a89aSChristophe Leroy static int cpm1_gpio16_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
4454128a89aSChristophe Leroy {
4464128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
4474128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
4484128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop = mm_gc->regs;
4494128a89aSChristophe Leroy 	unsigned long flags;
4504128a89aSChristophe Leroy 	u16 pin_mask = 1 << (15 - gpio);
4514128a89aSChristophe Leroy 
4524128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
4534128a89aSChristophe Leroy 
4544128a89aSChristophe Leroy 	setbits16(&iop->dir, pin_mask);
4554128a89aSChristophe Leroy 	__cpm1_gpio16_set(mm_gc, pin_mask, val);
4564128a89aSChristophe Leroy 
4574128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
4584128a89aSChristophe Leroy 
4594128a89aSChristophe Leroy 	return 0;
4604128a89aSChristophe Leroy }
4614128a89aSChristophe Leroy 
cpm1_gpio16_dir_in(struct gpio_chip * gc,unsigned int gpio)4624128a89aSChristophe Leroy static int cpm1_gpio16_dir_in(struct gpio_chip *gc, unsigned int gpio)
4634128a89aSChristophe Leroy {
4644128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
4654128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
4664128a89aSChristophe Leroy 	struct cpm_ioport16 __iomem *iop = mm_gc->regs;
4674128a89aSChristophe Leroy 	unsigned long flags;
4684128a89aSChristophe Leroy 	u16 pin_mask = 1 << (15 - gpio);
4694128a89aSChristophe Leroy 
4704128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
4714128a89aSChristophe Leroy 
4724128a89aSChristophe Leroy 	clrbits16(&iop->dir, pin_mask);
4734128a89aSChristophe Leroy 
4744128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
4754128a89aSChristophe Leroy 
4764128a89aSChristophe Leroy 	return 0;
4774128a89aSChristophe Leroy }
4784128a89aSChristophe Leroy 
cpm1_gpiochip_add16(struct device * dev)4794128a89aSChristophe Leroy int cpm1_gpiochip_add16(struct device *dev)
4804128a89aSChristophe Leroy {
4814128a89aSChristophe Leroy 	struct device_node *np = dev->of_node;
4824128a89aSChristophe Leroy 	struct cpm1_gpio16_chip *cpm1_gc;
4834128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc;
4844128a89aSChristophe Leroy 	struct gpio_chip *gc;
4854128a89aSChristophe Leroy 	u16 mask;
4864128a89aSChristophe Leroy 
4874128a89aSChristophe Leroy 	cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL);
4884128a89aSChristophe Leroy 	if (!cpm1_gc)
4894128a89aSChristophe Leroy 		return -ENOMEM;
4904128a89aSChristophe Leroy 
4914128a89aSChristophe Leroy 	spin_lock_init(&cpm1_gc->lock);
4924128a89aSChristophe Leroy 
4934128a89aSChristophe Leroy 	if (!of_property_read_u16(np, "fsl,cpm1-gpio-irq-mask", &mask)) {
4944128a89aSChristophe Leroy 		int i, j;
4954128a89aSChristophe Leroy 
4964128a89aSChristophe Leroy 		for (i = 0, j = 0; i < 16; i++)
4974128a89aSChristophe Leroy 			if (mask & (1 << (15 - i)))
4984128a89aSChristophe Leroy 				cpm1_gc->irq[i] = irq_of_parse_and_map(np, j++);
4994128a89aSChristophe Leroy 	}
5004128a89aSChristophe Leroy 
5014128a89aSChristophe Leroy 	mm_gc = &cpm1_gc->mm_gc;
5024128a89aSChristophe Leroy 	gc = &mm_gc->gc;
5034128a89aSChristophe Leroy 
5044128a89aSChristophe Leroy 	mm_gc->save_regs = cpm1_gpio16_save_regs;
5054128a89aSChristophe Leroy 	gc->ngpio = 16;
5064128a89aSChristophe Leroy 	gc->direction_input = cpm1_gpio16_dir_in;
5074128a89aSChristophe Leroy 	gc->direction_output = cpm1_gpio16_dir_out;
5084128a89aSChristophe Leroy 	gc->get = cpm1_gpio16_get;
5094128a89aSChristophe Leroy 	gc->set = cpm1_gpio16_set;
5104128a89aSChristophe Leroy 	gc->to_irq = cpm1_gpio16_to_irq;
5114128a89aSChristophe Leroy 	gc->parent = dev;
5124128a89aSChristophe Leroy 	gc->owner = THIS_MODULE;
5134128a89aSChristophe Leroy 
5144128a89aSChristophe Leroy 	return of_mm_gpiochip_add_data(np, mm_gc, cpm1_gc);
5154128a89aSChristophe Leroy }
5164128a89aSChristophe Leroy 
5174128a89aSChristophe Leroy struct cpm1_gpio32_chip {
5184128a89aSChristophe Leroy 	struct of_mm_gpio_chip mm_gc;
5194128a89aSChristophe Leroy 	spinlock_t lock;
5204128a89aSChristophe Leroy 
5214128a89aSChristophe Leroy 	/* shadowed data register to clear/set bits safely */
5224128a89aSChristophe Leroy 	u32 cpdata;
5234128a89aSChristophe Leroy };
5244128a89aSChristophe Leroy 
cpm1_gpio32_save_regs(struct of_mm_gpio_chip * mm_gc)5254128a89aSChristophe Leroy static void cpm1_gpio32_save_regs(struct of_mm_gpio_chip *mm_gc)
5264128a89aSChristophe Leroy {
5274128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc =
5284128a89aSChristophe Leroy 		container_of(mm_gc, struct cpm1_gpio32_chip, mm_gc);
5294128a89aSChristophe Leroy 	struct cpm_ioport32b __iomem *iop = mm_gc->regs;
5304128a89aSChristophe Leroy 
5314128a89aSChristophe Leroy 	cpm1_gc->cpdata = in_be32(&iop->dat);
5324128a89aSChristophe Leroy }
5334128a89aSChristophe Leroy 
cpm1_gpio32_get(struct gpio_chip * gc,unsigned int gpio)5344128a89aSChristophe Leroy static int cpm1_gpio32_get(struct gpio_chip *gc, unsigned int gpio)
5354128a89aSChristophe Leroy {
5364128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
5374128a89aSChristophe Leroy 	struct cpm_ioport32b __iomem *iop = mm_gc->regs;
5384128a89aSChristophe Leroy 	u32 pin_mask;
5394128a89aSChristophe Leroy 
5404128a89aSChristophe Leroy 	pin_mask = 1 << (31 - gpio);
5414128a89aSChristophe Leroy 
5424128a89aSChristophe Leroy 	return !!(in_be32(&iop->dat) & pin_mask);
5434128a89aSChristophe Leroy }
5444128a89aSChristophe Leroy 
__cpm1_gpio32_set(struct of_mm_gpio_chip * mm_gc,u32 pin_mask,int value)5454128a89aSChristophe Leroy static void __cpm1_gpio32_set(struct of_mm_gpio_chip *mm_gc, u32 pin_mask,
5464128a89aSChristophe Leroy 	int value)
5474128a89aSChristophe Leroy {
5484128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
5494128a89aSChristophe Leroy 	struct cpm_ioport32b __iomem *iop = mm_gc->regs;
5504128a89aSChristophe Leroy 
5514128a89aSChristophe Leroy 	if (value)
5524128a89aSChristophe Leroy 		cpm1_gc->cpdata |= pin_mask;
5534128a89aSChristophe Leroy 	else
5544128a89aSChristophe Leroy 		cpm1_gc->cpdata &= ~pin_mask;
5554128a89aSChristophe Leroy 
5564128a89aSChristophe Leroy 	out_be32(&iop->dat, cpm1_gc->cpdata);
5574128a89aSChristophe Leroy }
5584128a89aSChristophe Leroy 
cpm1_gpio32_set(struct gpio_chip * gc,unsigned int gpio,int value)5594128a89aSChristophe Leroy static void cpm1_gpio32_set(struct gpio_chip *gc, unsigned int gpio, int value)
5604128a89aSChristophe Leroy {
5614128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
5624128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
5634128a89aSChristophe Leroy 	unsigned long flags;
5644128a89aSChristophe Leroy 	u32 pin_mask = 1 << (31 - gpio);
5654128a89aSChristophe Leroy 
5664128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
5674128a89aSChristophe Leroy 
5684128a89aSChristophe Leroy 	__cpm1_gpio32_set(mm_gc, pin_mask, value);
5694128a89aSChristophe Leroy 
5704128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
5714128a89aSChristophe Leroy }
5724128a89aSChristophe Leroy 
cpm1_gpio32_dir_out(struct gpio_chip * gc,unsigned int gpio,int val)5734128a89aSChristophe Leroy static int cpm1_gpio32_dir_out(struct gpio_chip *gc, unsigned int gpio, int val)
5744128a89aSChristophe Leroy {
5754128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
5764128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
5774128a89aSChristophe Leroy 	struct cpm_ioport32b __iomem *iop = mm_gc->regs;
5784128a89aSChristophe Leroy 	unsigned long flags;
5794128a89aSChristophe Leroy 	u32 pin_mask = 1 << (31 - gpio);
5804128a89aSChristophe Leroy 
5814128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
5824128a89aSChristophe Leroy 
5834128a89aSChristophe Leroy 	setbits32(&iop->dir, pin_mask);
5844128a89aSChristophe Leroy 	__cpm1_gpio32_set(mm_gc, pin_mask, val);
5854128a89aSChristophe Leroy 
5864128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
5874128a89aSChristophe Leroy 
5884128a89aSChristophe Leroy 	return 0;
5894128a89aSChristophe Leroy }
5904128a89aSChristophe Leroy 
cpm1_gpio32_dir_in(struct gpio_chip * gc,unsigned int gpio)5914128a89aSChristophe Leroy static int cpm1_gpio32_dir_in(struct gpio_chip *gc, unsigned int gpio)
5924128a89aSChristophe Leroy {
5934128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc = to_of_mm_gpio_chip(gc);
5944128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc = gpiochip_get_data(&mm_gc->gc);
5954128a89aSChristophe Leroy 	struct cpm_ioport32b __iomem *iop = mm_gc->regs;
5964128a89aSChristophe Leroy 	unsigned long flags;
5974128a89aSChristophe Leroy 	u32 pin_mask = 1 << (31 - gpio);
5984128a89aSChristophe Leroy 
5994128a89aSChristophe Leroy 	spin_lock_irqsave(&cpm1_gc->lock, flags);
6004128a89aSChristophe Leroy 
6014128a89aSChristophe Leroy 	clrbits32(&iop->dir, pin_mask);
6024128a89aSChristophe Leroy 
6034128a89aSChristophe Leroy 	spin_unlock_irqrestore(&cpm1_gc->lock, flags);
6044128a89aSChristophe Leroy 
6054128a89aSChristophe Leroy 	return 0;
6064128a89aSChristophe Leroy }
6074128a89aSChristophe Leroy 
cpm1_gpiochip_add32(struct device * dev)6084128a89aSChristophe Leroy int cpm1_gpiochip_add32(struct device *dev)
6094128a89aSChristophe Leroy {
6104128a89aSChristophe Leroy 	struct device_node *np = dev->of_node;
6114128a89aSChristophe Leroy 	struct cpm1_gpio32_chip *cpm1_gc;
6124128a89aSChristophe Leroy 	struct of_mm_gpio_chip *mm_gc;
6134128a89aSChristophe Leroy 	struct gpio_chip *gc;
6144128a89aSChristophe Leroy 
6154128a89aSChristophe Leroy 	cpm1_gc = kzalloc(sizeof(*cpm1_gc), GFP_KERNEL);
6164128a89aSChristophe Leroy 	if (!cpm1_gc)
6174128a89aSChristophe Leroy 		return -ENOMEM;
6184128a89aSChristophe Leroy 
6194128a89aSChristophe Leroy 	spin_lock_init(&cpm1_gc->lock);
6204128a89aSChristophe Leroy 
6214128a89aSChristophe Leroy 	mm_gc = &cpm1_gc->mm_gc;
6224128a89aSChristophe Leroy 	gc = &mm_gc->gc;
6234128a89aSChristophe Leroy 
6244128a89aSChristophe Leroy 	mm_gc->save_regs = cpm1_gpio32_save_regs;
6254128a89aSChristophe Leroy 	gc->ngpio = 32;
6264128a89aSChristophe Leroy 	gc->direction_input = cpm1_gpio32_dir_in;
6274128a89aSChristophe Leroy 	gc->direction_output = cpm1_gpio32_dir_out;
6284128a89aSChristophe Leroy 	gc->get = cpm1_gpio32_get;
6294128a89aSChristophe Leroy 	gc->set = cpm1_gpio32_set;
6304128a89aSChristophe Leroy 	gc->parent = dev;
6314128a89aSChristophe Leroy 	gc->owner = THIS_MODULE;
6324128a89aSChristophe Leroy 
6334128a89aSChristophe Leroy 	return of_mm_gpiochip_add_data(np, mm_gc, cpm1_gc);
6344128a89aSChristophe Leroy }
6354128a89aSChristophe Leroy 
6364128a89aSChristophe Leroy #endif /* CONFIG_8xx_GPIO */
637