Home | History | Annotate | Line # | Download | only in gumstix
gxio.c revision 1.21
      1  1.21  kiyohara /*	$NetBSD: gxio.c,v 1.21 2016/10/15 15:27:18 kiyohara Exp $ */
      2   1.1  kiyohara /*
      3   1.3  kiyohara  * Copyright (C) 2005, 2006, 2007 WIDE Project and SOUM Corporation.
      4   1.1  kiyohara  * All rights reserved.
      5   1.1  kiyohara  *
      6   1.1  kiyohara  * Written by Takashi Kiyohara and Susumu Miki for WIDE Project and SOUM
      7   1.1  kiyohara  * Corporation.
      8   1.1  kiyohara  *
      9   1.1  kiyohara  * Redistribution and use in source and binary forms, with or without
     10   1.1  kiyohara  * modification, are permitted provided that the following conditions
     11   1.1  kiyohara  * are met:
     12   1.1  kiyohara  * 1. Redistributions of source code must retain the above copyright
     13   1.1  kiyohara  *    notice, this list of conditions and the following disclaimer.
     14   1.1  kiyohara  * 2. Redistributions in binary form must reproduce the above copyright
     15   1.1  kiyohara  *    notice, this list of conditions and the following disclaimer in the
     16   1.1  kiyohara  *    documentation and/or other materials provided with the distribution.
     17   1.1  kiyohara  * 3. Neither the name of the project nor the name of SOUM Corporation
     18   1.1  kiyohara  *    may be used to endorse or promote products derived from this software
     19   1.1  kiyohara  *    without specific prior written permission.
     20   1.1  kiyohara  *
     21   1.1  kiyohara  * THIS SOFTWARE IS PROVIDED BY THE PROJECT and SOUM CORPORATION ``AS IS''
     22   1.1  kiyohara  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     23   1.1  kiyohara  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     24   1.1  kiyohara  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT AND SOUM CORPORATION
     25   1.1  kiyohara  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     26   1.1  kiyohara  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     27   1.1  kiyohara  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     28   1.1  kiyohara  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     29   1.1  kiyohara  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     30   1.1  kiyohara  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     31   1.1  kiyohara  * POSSIBILITY OF SUCH DAMAGE.
     32   1.1  kiyohara  */
     33   1.1  kiyohara #include <sys/cdefs.h>
     34  1.21  kiyohara __KERNEL_RCSID(0, "$NetBSD: gxio.c,v 1.21 2016/10/15 15:27:18 kiyohara Exp $");
     35   1.3  kiyohara 
     36  1.15  kiyohara #include "opt_cputypes.h"
     37  1.15  kiyohara #include "opt_gumstix.h"
     38   1.3  kiyohara #include "opt_gxio.h"
     39  1.17  kiyohara #if defined(OVERO)
     40  1.17  kiyohara #include "opt_omap.h"
     41  1.17  kiyohara #endif
     42   1.1  kiyohara 
     43   1.1  kiyohara #include <sys/param.h>
     44   1.1  kiyohara #include <sys/device.h>
     45   1.1  kiyohara #include <sys/errno.h>
     46  1.10  kiyohara #include <sys/kernel.h>
     47   1.1  kiyohara 
     48   1.1  kiyohara #include <sys/systm.h>
     49   1.1  kiyohara 
     50   1.1  kiyohara #include <machine/bootconfig.h>
     51   1.1  kiyohara 
     52  1.16  kiyohara #include <arm/omap/omap2_gpmcreg.h>
     53  1.21  kiyohara #if defined(OMAP2)
     54  1.15  kiyohara #include <arm/omap/omap2_reg.h>
     55  1.17  kiyohara #if defined(OMAP3530)
     56  1.16  kiyohara #include <arm/omap/omap2_intr.h>
     57  1.17  kiyohara #endif
     58  1.21  kiyohara #endif
     59  1.15  kiyohara #include <arm/omap/omap_var.h>
     60  1.21  kiyohara #include <arm/omap/tifbvar.h>
     61  1.21  kiyohara #include <arm/omap/ti_iicreg.h>
     62  1.21  kiyohara #if defined(CPU_XSCALE)
     63   1.1  kiyohara #include <arm/xscale/pxa2x0cpu.h>
     64  1.15  kiyohara #endif
     65   1.1  kiyohara #include <arm/xscale/pxa2x0reg.h>
     66   1.1  kiyohara #include <arm/xscale/pxa2x0var.h>
     67   1.1  kiyohara #include <arm/xscale/pxa2x0_gpio.h>
     68  1.16  kiyohara #include <evbarm/gumstix/gumstixreg.h>
     69   1.1  kiyohara #include <evbarm/gumstix/gumstixvar.h>
     70   1.1  kiyohara 
     71  1.16  kiyohara #include "ioconf.h"
     72   1.1  kiyohara #include "locators.h"
     73   1.1  kiyohara 
     74   1.1  kiyohara 
     75   1.3  kiyohara struct gxioconf {
     76   1.3  kiyohara 	const char *name;
     77   1.4  kiyohara 	void (*config)(void);
     78   1.3  kiyohara };
     79   1.3  kiyohara 
     80  1.16  kiyohara #if defined(GUMSTIX)
     81  1.10  kiyohara static int gxiomatch(device_t, cfdata_t, void *);
     82   1.8  kiyohara static void gxioattach(device_t, device_t, void *);
     83  1.10  kiyohara static int gxiosearch(device_t, cfdata_t, const int *, void *);
     84   1.1  kiyohara static int gxioprint(void *, const char *);
     85  1.16  kiyohara 
     86  1.16  kiyohara CFATTACH_DECL_NEW(gxio, sizeof(struct gxio_softc),
     87  1.16  kiyohara     gxiomatch, gxioattach, NULL, NULL);
     88  1.15  kiyohara #endif
     89   1.1  kiyohara 
     90  1.21  kiyohara void gxio_config(void);
     91   1.6  kiyohara void gxio_config_expansion(char *);
     92  1.16  kiyohara #if defined(GUMSTIX)
     93   1.6  kiyohara static void basix_config(void);
     94   1.4  kiyohara static void cfstix_config(void);
     95   1.4  kiyohara static void etherstix_config(void);
     96   1.4  kiyohara static void netcf_config(void);
     97  1.14  kiyohara static void netcf_vx_config(void);
     98   1.4  kiyohara static void netduommc_config(void);
     99   1.4  kiyohara static void netduo_config(void);
    100  1.10  kiyohara static void netmicrosd_config(void);
    101  1.10  kiyohara static void netwifimicrosd_config(void);
    102   1.4  kiyohara static void netmmc_config(void);
    103  1.10  kiyohara static void wifistix_config(void);
    104   1.4  kiyohara static void wifistix_cf_config(void);
    105  1.16  kiyohara #elif defined(OVERO)
    106  1.16  kiyohara static void eth0_config(void);
    107  1.16  kiyohara static void eth1_config(void);
    108  1.21  kiyohara static void dvi_config(void);
    109  1.21  kiyohara static void lcd_config(char);
    110  1.21  kiyohara static void header_40pin_config(int);
    111  1.21  kiyohara 
    112  1.16  kiyohara static void chestnut_config(void);
    113  1.21  kiyohara static void gallop_config(void);
    114  1.21  kiyohara static void summit_config(void);
    115  1.16  kiyohara static void tobi_config(void);
    116  1.16  kiyohara static void tobiduo_config(void);
    117  1.21  kiyohara #elif defined(DUOVERO)
    118  1.21  kiyohara static void ehci_config(void);
    119  1.21  kiyohara 
    120  1.21  kiyohara static void parlor_config(void);
    121  1.21  kiyohara #elif defined(PEPPER)
    122  1.21  kiyohara static void lcd_config(void);
    123  1.21  kiyohara static void pepper43_config(void);
    124  1.21  kiyohara 
    125  1.21  kiyohara static void pepper_config(void);
    126  1.21  kiyohara static void c_config(void);
    127  1.21  kiyohara static void dvi_config(void);
    128  1.21  kiyohara static void r_config(void);
    129  1.21  kiyohara #endif
    130  1.21  kiyohara #if defined(OVERO) || defined(DUOVERO)
    131  1.21  kiyohara struct omap_mux_conf;
    132  1.21  kiyohara static void smsh_config(struct omap_mux_conf *, int, int);
    133  1.21  kiyohara #endif
    134  1.21  kiyohara #if defined(OVERO) || defined(DUOVERO) || defined(PEPPER)
    135  1.21  kiyohara static void __udelay(unsigned int);
    136  1.21  kiyohara #endif
    137  1.21  kiyohara #if defined(PEPPER)
    138  1.21  kiyohara static int read_i2c_device(const vaddr_t, uint16_t, uint8_t, int, uint8_t *);
    139  1.15  kiyohara #endif
    140   1.1  kiyohara 
    141  1.10  kiyohara #if defined(CPU_XSCALE_PXA250)
    142  1.21  kiyohara 
    143  1.10  kiyohara static struct pxa2x0_gpioconf pxa255dep_gpioconf[] = {
    144   1.3  kiyohara 	/* Bluetooth module configuration */
    145   1.3  kiyohara 	{  7, GPIO_OUT | GPIO_SET },	/* power on */
    146   1.3  kiyohara 	{ 12, GPIO_ALT_FN_1_OUT },	/* 32kHz out. required by SingleStone */
    147   1.3  kiyohara 
    148   1.3  kiyohara 	/* AC97 configuration */
    149  1.10  kiyohara 	{ 29, GPIO_ALT_FN_1_IN },	/* SDATA_IN0 */
    150  1.10  kiyohara 
    151  1.10  kiyohara 	/* FFUART configuration */
    152  1.10  kiyohara 	{ 35, GPIO_ALT_FN_1_IN },	/* CTS */
    153  1.10  kiyohara 	{ 41, GPIO_ALT_FN_2_OUT },	/* RTS */
    154   1.3  kiyohara 
    155   1.3  kiyohara #ifndef GXIO_BLUETOOTH_ON_HWUART
    156   1.3  kiyohara 	/* BTUART configuration */
    157  1.10  kiyohara 	{ 44, GPIO_ALT_FN_1_IN },	/* BTCTS */
    158  1.10  kiyohara 	{ 45, GPIO_ALT_FN_2_OUT },	/* BTRTS */
    159   1.3  kiyohara #else
    160   1.3  kiyohara 	/* HWUART configuration */
    161   1.3  kiyohara 	{ 42, GPIO_ALT_FN_3_IN },	/* HWRXD */
    162   1.3  kiyohara 	{ 43, GPIO_ALT_FN_3_OUT },	/* HWTXD */
    163  1.10  kiyohara 	{ 44, GPIO_ALT_FN_3_IN },	/* HWCTS */
    164  1.10  kiyohara 	{ 45, GPIO_ALT_FN_3_OUT },	/* HWRTS */
    165   1.3  kiyohara #endif
    166   1.3  kiyohara 
    167   1.3  kiyohara #ifndef GXIO_BLUETOOTH_ON_HWUART
    168   1.3  kiyohara 	/* HWUART configuration */
    169   1.3  kiyohara 	{ 48, GPIO_ALT_FN_1_OUT },	/* HWTXD */
    170   1.3  kiyohara 	{ 49, GPIO_ALT_FN_1_IN },	/* HWRXD */
    171   1.3  kiyohara 	{ 50, GPIO_ALT_FN_1_IN },	/* HWCTS */
    172   1.3  kiyohara 	{ 51, GPIO_ALT_FN_1_OUT },	/* HWRTS */
    173   1.3  kiyohara #endif
    174   1.3  kiyohara 
    175   1.3  kiyohara 	{ -1 }
    176   1.1  kiyohara };
    177  1.10  kiyohara #endif
    178  1.10  kiyohara #if defined(CPU_XSCALE_PXA270)
    179  1.10  kiyohara static struct pxa2x0_gpioconf verdexdep_gpioconf[] = {
    180  1.10  kiyohara 	/* Bluetooth module configuration */
    181  1.10  kiyohara 	{   9, GPIO_ALT_FN_3_OUT },	/* CHOUT<0> */
    182  1.13  kiyohara 	{  12, GPIO_OUT | GPIO_SET },
    183  1.10  kiyohara 
    184  1.12  kiyohara 	/* LCD configuration */
    185  1.12  kiyohara 	{  17, GPIO_IN },		/* backlight on */
    186  1.12  kiyohara 
    187  1.10  kiyohara 	/* FFUART configuration */
    188  1.10  kiyohara 	{  34, GPIO_ALT_FN_1_IN },	/* FFRXD */
    189  1.10  kiyohara 	{  39, GPIO_ALT_FN_2_OUT },	/* FFTXD */
    190  1.10  kiyohara 
    191  1.10  kiyohara 	/* BTUART configuration */
    192  1.10  kiyohara 	{  42, GPIO_ALT_FN_1_IN },	/* BTRXD */
    193  1.10  kiyohara 	{  43, GPIO_ALT_FN_2_OUT },	/* BTTXD */
    194  1.10  kiyohara 	{  44, GPIO_ALT_FN_1_IN },	/* BTCTS */
    195  1.10  kiyohara 	{  45, GPIO_ALT_FN_2_OUT },	/* BTRTS */
    196  1.10  kiyohara 
    197  1.10  kiyohara 	/* AC97 configuration */
    198  1.10  kiyohara 	{  29, GPIO_ALT_FN_1_IN },	/* SDATA_IN0 */
    199  1.10  kiyohara 
    200  1.10  kiyohara 	{ -1 }
    201  1.10  kiyohara };
    202  1.21  kiyohara 
    203  1.21  kiyohara #elif defined(OMAP2)
    204  1.21  kiyohara 
    205  1.21  kiyohara struct omap_mux_conf {
    206  1.21  kiyohara 	int offset;
    207  1.21  kiyohara 	uint32_t value;
    208  1.21  kiyohara /* OMAP3/4 register values */
    209  1.21  kiyohara #define WAKEUPEVENT		(1 << 15)
    210  1.21  kiyohara #define WAKEUPENABLE		(1 << 14)
    211  1.21  kiyohara #define OFFMODEPULLTYPESELECT	(1 << 13)
    212  1.21  kiyohara #define OFFMODEPULLUDENABLE	(1 << 12)
    213  1.21  kiyohara #define OFFMODEOUTVALUE		(1 << 11)
    214  1.21  kiyohara #define OFFMODEOUTENABLE	(1 << 10)
    215  1.21  kiyohara #define OFFMODEENABLE		(1 << 9)
    216  1.21  kiyohara #define INPUTENABLE		(1 << 8)
    217  1.21  kiyohara #define PULLTYPESELECT		(1 << 4)
    218  1.21  kiyohara #define PULLUDENABLE		(1 << 3)
    219  1.21  kiyohara #define MUXMODE(n)		((n) & 0x7)
    220  1.21  kiyohara 
    221  1.21  kiyohara /* Sitara AM3xxx register values */
    222  1.21  kiyohara #define SLEWCTRL		(1 << 6)
    223  1.21  kiyohara #define RXACTIVE		(1 << 5)
    224  1.21  kiyohara #define PUTYPESEL		(1 << 4)
    225  1.21  kiyohara #define PUDEN			(1 << 3)
    226  1.21  kiyohara #define MMODE(n)		((n) & 0x7)
    227  1.21  kiyohara };
    228  1.21  kiyohara struct omap_gpio_conf {
    229  1.21  kiyohara 	int pin;
    230  1.21  kiyohara 	enum {
    231  1.21  kiyohara 		conf_input = -1,
    232  1.21  kiyohara 		conf_output_0,
    233  1.21  kiyohara 		conf_output_1,
    234  1.21  kiyohara 	} conf;
    235  1.21  kiyohara };
    236  1.21  kiyohara 
    237  1.21  kiyohara static void gxio_omap_mux_config(const struct omap_mux_conf []);
    238  1.21  kiyohara static int gxio_omap_mux_config_address(const char *, unsigned long,
    239  1.21  kiyohara 					const struct omap_mux_conf[],
    240  1.21  kiyohara 					const struct omap_mux_conf[]);
    241  1.21  kiyohara static void gxio_omap_gpio_config(const struct omap_gpio_conf[]);
    242  1.21  kiyohara void gxio_omap_gpio_write(int, int);
    243  1.21  kiyohara 
    244  1.21  kiyohara static const struct omap_mux_conf overo_mux_i2c3_conf[] = {
    245  1.21  kiyohara 	{ 0x1c2, MUXMODE(0) | INPUTENABLE },		/* i2c3_scl */
    246  1.21  kiyohara 	{ 0x1c4, MUXMODE(0) | INPUTENABLE },		/* i2c3_sda */
    247  1.21  kiyohara 	{ -1 }
    248  1.21  kiyohara };
    249  1.21  kiyohara static const struct omap_mux_conf overo_mux_mmchs2_conf[] = {
    250  1.21  kiyohara 	{ 0x158,					/* mmc2_clk */
    251  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    252  1.21  kiyohara 	{ 0x15a,					/* mmc2_cmd */
    253  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    254  1.21  kiyohara 	{ 0x15c,					/* mmc2_dat0 */
    255  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    256  1.21  kiyohara 	{ 0x15e,					/* mmc2_dat1 */
    257  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    258  1.21  kiyohara 	{ 0x160,					/* mmc2_dat2 */
    259  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    260  1.21  kiyohara 	{ 0x162,					/* mmc2_dat3 */
    261  1.21  kiyohara 	  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    262  1.21  kiyohara 	{ -1 }
    263  1.21  kiyohara };
    264  1.21  kiyohara static const struct omap_mux_conf overo_mux_wireless_conf[] = {
    265  1.21  kiyohara 	{ 0x0b4, MUXMODE(4) },				/* gpio_54:BT_nPOWERON*/
    266  1.21  kiyohara 	{ 0x0bc, MUXMODE(4) | INPUTENABLE },		/* gpio_58: WIFI_IRQ */
    267  1.21  kiyohara 	{ 0x19c, MUXMODE(4) },				/* gpio_164:BT_nRESET */
    268  1.21  kiyohara 	{ 0x5e0, MUXMODE(4) },				/* gpio_16: W2W_nRESET*/
    269  1.21  kiyohara 	{ -1 }
    270  1.21  kiyohara };
    271  1.21  kiyohara 
    272  1.21  kiyohara static const struct omap_mux_conf duovero_mux_led_conf[] = {
    273  1.21  kiyohara 	{ 0x116, MUXMODE(3) },				/* GPIO 122 */
    274  1.21  kiyohara 	{ -1 }
    275  1.21  kiyohara };
    276  1.21  kiyohara static const struct omap_mux_conf duovero_mux_button_conf[] = {
    277  1.21  kiyohara 	{ 0x114,					/* GPIO 121 */
    278  1.21  kiyohara 	  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
    279  1.21  kiyohara 	{ -1 }
    280  1.21  kiyohara };
    281  1.21  kiyohara 
    282  1.21  kiyohara static const struct omap_mux_conf pepper_mux_led_conf[] = {
    283  1.21  kiyohara 	{ 0x850, MMODE(7) | PUDEN },			/* GPIO 52: Blue */
    284  1.21  kiyohara 	{ 0x854, MMODE(7) | PUDEN },			/* GPIO 53: Red */
    285  1.21  kiyohara 	{ -1 }
    286  1.21  kiyohara };
    287  1.21  kiyohara static const struct omap_mux_conf pepper_mux_button_conf[] = {
    288  1.21  kiyohara 	{ 0x858, MMODE(7) | PUTYPESEL | RXACTIVE },	/* GPIO 54 */
    289  1.21  kiyohara 	{ -1 }
    290  1.21  kiyohara };
    291  1.21  kiyohara static const struct omap_mux_conf pepper_mux_mmchs3_conf[] = {
    292  1.21  kiyohara 	{ 0x844, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_DAT0 */
    293  1.21  kiyohara 	{ 0x848, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_DAT1 */
    294  1.21  kiyohara 	{ 0x84c, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_DAT2 */
    295  1.21  kiyohara 	{ 0x878, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_DAT3 */
    296  1.21  kiyohara 	{ 0x888, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_CMD */
    297  1.21  kiyohara 	{ 0x88c, MMODE(3) | PUTYPESEL | RXACTIVE },	/* MMC2_CLK */
    298  1.21  kiyohara 	{ -1 }
    299  1.21  kiyohara };
    300  1.21  kiyohara static const struct omap_mux_conf pepper_mux_audio_codec_conf[] = {
    301  1.21  kiyohara 	{ 0x840, MMODE(7) | PUDEN },			/* GPIO 48: #Reset */
    302  1.21  kiyohara 	{ -1 }
    303  1.21  kiyohara };
    304  1.21  kiyohara 
    305  1.10  kiyohara #endif
    306   1.1  kiyohara 
    307  1.21  kiyohara static const struct gxioconf gxioconflist[] = {
    308  1.16  kiyohara #if defined(GUMSTIX)
    309   1.6  kiyohara 	{ "basix",		basix_config },
    310   1.1  kiyohara 	{ "cfstix",		cfstix_config },
    311   1.1  kiyohara 	{ "etherstix",		etherstix_config },
    312   1.1  kiyohara 	{ "netcf",		netcf_config },
    313  1.14  kiyohara 	{ "netcf-vx",		netcf_vx_config },
    314   1.3  kiyohara 	{ "netduo-mmc",		netduommc_config },
    315   1.1  kiyohara 	{ "netduo",		netduo_config },
    316  1.10  kiyohara 	{ "netmicrosd",		netmicrosd_config },
    317  1.10  kiyohara 	{ "netmicrosd-vx",	netmicrosd_config },
    318  1.10  kiyohara 	{ "netwifimicrosd",	netwifimicrosd_config },
    319   1.1  kiyohara 	{ "netmmc",		netmmc_config },
    320  1.10  kiyohara 	{ "netpro-vx",		netwifimicrosd_config },
    321   1.4  kiyohara 	{ "wifistix-cf",	wifistix_cf_config },
    322  1.10  kiyohara 	{ "wifistix",		wifistix_config },
    323  1.16  kiyohara #elif defined(OVERO)
    324  1.16  kiyohara 	{ "chestnut43",		chestnut_config },
    325  1.21  kiyohara 	{ "gallop43",		gallop_config },
    326  1.21  kiyohara 	{ "summit",		summit_config },
    327  1.16  kiyohara 	{ "tobi",		tobi_config },
    328  1.16  kiyohara 	{ "tobi-duo",		tobiduo_config },
    329  1.21  kiyohara #elif defined(DUOVERO)
    330  1.21  kiyohara 	{ "parlor",		parlor_config },
    331  1.21  kiyohara #elif defined(PEPPER)
    332  1.21  kiyohara 	{ "43c",		c_config },
    333  1.21  kiyohara 	{ "43r",		r_config },
    334  1.21  kiyohara 	{ "dvi",		dvi_config },
    335  1.15  kiyohara #endif
    336   1.1  kiyohara 	{ NULL }
    337   1.1  kiyohara };
    338   1.1  kiyohara 
    339  1.10  kiyohara int gxpcic_gpio_reset;
    340  1.10  kiyohara struct gxpcic_slot_irqs gxpcic_slot_irqs[2] = { { 0, -1, -1 }, { 0, -1, -1 } };
    341  1.10  kiyohara 
    342   1.1  kiyohara 
    343  1.16  kiyohara #if defined(GUMSTIX)
    344   1.1  kiyohara /* ARGSUSED */
    345   1.1  kiyohara static int
    346  1.10  kiyohara gxiomatch(device_t parent, cfdata_t match, void *aux)
    347   1.1  kiyohara {
    348  1.16  kiyohara 
    349  1.10  kiyohara 	struct pxaip_attach_args *pxa = aux;
    350   1.1  kiyohara 	bus_space_tag_t iot = &pxa2x0_bs_tag;
    351   1.1  kiyohara 	bus_space_handle_t ioh;
    352   1.1  kiyohara 
    353  1.10  kiyohara 	if (strcmp(pxa->pxa_name, match->cf_name) != 0 ||
    354  1.10  kiyohara 	    pxa->pxa_addr != PXAIPCF_ADDR_DEFAULT)
    355  1.10  kiyohara 		 return 0;
    356  1.10  kiyohara 
    357   1.1  kiyohara 	if (bus_space_map(iot,
    358   1.1  kiyohara 	    PXA2X0_MEMCTL_BASE, PXA2X0_MEMCTL_SIZE, 0, &ioh))
    359  1.16  kiyohara 		return 0;
    360   1.1  kiyohara 	bus_space_unmap(iot, ioh, PXA2X0_MEMCTL_SIZE);
    361   1.1  kiyohara 
    362   1.1  kiyohara 	/* nothing */
    363  1.16  kiyohara 	return 1;
    364   1.1  kiyohara }
    365   1.1  kiyohara 
    366   1.1  kiyohara /* ARGSUSED */
    367   1.1  kiyohara static void
    368   1.8  kiyohara gxioattach(device_t parent, device_t self, void *aux)
    369   1.1  kiyohara {
    370   1.3  kiyohara 	struct gxio_softc *sc = device_private(self);
    371   1.1  kiyohara 
    372   1.3  kiyohara 	aprint_normal("\n");
    373   1.3  kiyohara 	aprint_naive("\n");
    374   1.1  kiyohara 
    375   1.8  kiyohara 	sc->sc_dev = self;
    376   1.1  kiyohara 	sc->sc_iot = &pxa2x0_bs_tag;
    377   1.1  kiyohara 
    378   1.1  kiyohara 	if (bus_space_map(sc->sc_iot,
    379   1.1  kiyohara 	    PXA2X0_MEMCTL_BASE, PXA2X0_MEMCTL_SIZE, 0, &sc->sc_ioh))
    380   1.1  kiyohara 		return;
    381   1.1  kiyohara 
    382   1.1  kiyohara 	/*
    383  1.16  kiyohara 	 *  Attach each gumstix(busheader)/overo expansion board devices.
    384   1.1  kiyohara 	 */
    385   1.1  kiyohara 	config_search_ia(gxiosearch, self, "gxio", NULL);
    386   1.1  kiyohara }
    387   1.1  kiyohara 
    388   1.1  kiyohara /* ARGSUSED */
    389   1.1  kiyohara static int
    390  1.10  kiyohara gxiosearch(device_t parent, cfdata_t cf, const int *ldesc, void *aux)
    391   1.1  kiyohara {
    392   1.3  kiyohara 	struct gxio_softc *sc = device_private(parent);
    393   1.1  kiyohara 	struct gxio_attach_args gxa;
    394   1.1  kiyohara 
    395   1.1  kiyohara 	gxa.gxa_sc = sc;
    396   1.1  kiyohara 	gxa.gxa_iot = sc->sc_iot;
    397   1.1  kiyohara 	gxa.gxa_addr = cf->cf_loc[GXIOCF_ADDR];
    398   1.1  kiyohara 	gxa.gxa_gpirq = cf->cf_loc[GXIOCF_GPIRQ];
    399   1.1  kiyohara 
    400   1.1  kiyohara 	if (config_match(parent, cf, &gxa))
    401   1.1  kiyohara 		config_attach(parent, cf, &gxa, gxioprint);
    402   1.1  kiyohara 
    403  1.16  kiyohara 	return 0;
    404   1.1  kiyohara }
    405   1.1  kiyohara 
    406   1.1  kiyohara /* ARGSUSED */
    407   1.1  kiyohara static int
    408   1.1  kiyohara gxioprint(void *aux, const char *name)
    409   1.1  kiyohara {
    410   1.1  kiyohara 	struct gxio_attach_args *gxa = (struct gxio_attach_args *)aux;
    411   1.1  kiyohara 
    412   1.1  kiyohara 	if (gxa->gxa_addr != GXIOCF_ADDR_DEFAULT)
    413   1.1  kiyohara 		printf(" addr 0x%lx", gxa->gxa_addr);
    414   1.1  kiyohara 	if (gxa->gxa_gpirq > 0)
    415   1.1  kiyohara 		printf(" gpirq %d", gxa->gxa_gpirq);
    416  1.16  kiyohara 	return UNCONF;
    417   1.1  kiyohara }
    418  1.15  kiyohara #endif
    419   1.1  kiyohara 
    420   1.1  kiyohara 
    421  1.21  kiyohara #if defined(GUMSTIX)
    422   1.1  kiyohara /*
    423   1.3  kiyohara  * configure for GPIO pin and expansion boards.
    424   1.1  kiyohara  */
    425   1.1  kiyohara void
    426  1.21  kiyohara gxio_config(void)
    427   1.3  kiyohara {
    428  1.10  kiyohara #if defined(CPU_XSCALE_PXA250)
    429   1.5  kiyohara 	struct pxa2x0_gpioconf *gumstix_gpioconf[] = {
    430   1.5  kiyohara 		pxa25x_com_ffuart_gpioconf,
    431   1.5  kiyohara 		pxa25x_com_stuart_gpioconf,
    432   1.5  kiyohara #ifndef GXIO_BLUETOOTH_ON_HWUART
    433   1.5  kiyohara 		pxa25x_com_btuart_gpioconf,
    434   1.5  kiyohara #endif
    435   1.5  kiyohara 		pxa25x_com_hwuart_gpioconf,
    436   1.5  kiyohara 		pxa25x_i2c_gpioconf,
    437   1.5  kiyohara 		pxa25x_pxaacu_gpioconf,
    438  1.10  kiyohara 		pxa255dep_gpioconf,
    439  1.10  kiyohara 		NULL
    440  1.10  kiyohara 	};
    441  1.10  kiyohara #endif
    442  1.10  kiyohara #if defined(CPU_XSCALE_PXA270)
    443  1.10  kiyohara 	struct pxa2x0_gpioconf *verdex_gpioconf[] = {
    444  1.10  kiyohara 		pxa27x_com_ffuart_gpioconf,
    445  1.10  kiyohara 		pxa27x_com_stuart_gpioconf,
    446  1.10  kiyohara 		pxa27x_com_btuart_gpioconf,
    447  1.10  kiyohara 		pxa27x_i2c_gpioconf,
    448  1.10  kiyohara 		pxa27x_pxaacu_gpioconf,
    449  1.10  kiyohara 		pxa27x_pxamci_gpioconf,
    450  1.10  kiyohara 		pxa27x_ohci_gpioconf,
    451  1.10  kiyohara 		verdexdep_gpioconf,
    452   1.5  kiyohara 		NULL
    453   1.5  kiyohara 	};
    454  1.10  kiyohara #endif
    455   1.3  kiyohara 
    456   1.3  kiyohara 	/* XXX: turn off for power of bluetooth module */
    457  1.13  kiyohara #if defined(CPU_XSCALE_PXA250)
    458   1.3  kiyohara 	pxa2x0_gpio_set_function(7, GPIO_OUT | GPIO_CLR);
    459  1.13  kiyohara #elif defined(CPU_XSCALE_PXA270)
    460  1.13  kiyohara 	pxa2x0_gpio_set_function(12, GPIO_OUT | GPIO_CLR);
    461  1.13  kiyohara #endif
    462   1.3  kiyohara 	delay(100);
    463   1.3  kiyohara 
    464  1.10  kiyohara #if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
    465  1.10  kiyohara 	pxa2x0_gpio_config(
    466  1.10  kiyohara 	    (CPU_IS_PXA250) ? gumstix_gpioconf : verdex_gpioconf);
    467  1.15  kiyohara #elif defined(CPU_XSCALE_PXA270) || defined(CPU_XSCALE_PXA250)
    468  1.10  kiyohara #if defined(CPU_XSCALE_PXA270)
    469  1.10  kiyohara 	pxa2x0_gpio_config(verdex_gpioconf);
    470  1.10  kiyohara #else
    471   1.5  kiyohara 	pxa2x0_gpio_config(gumstix_gpioconf);
    472  1.10  kiyohara #endif
    473  1.10  kiyohara #endif
    474   1.3  kiyohara }
    475  1.21  kiyohara #elif defined(OVERO) || defined(DUOVERO) || defined(PEPPER)
    476  1.21  kiyohara static void
    477  1.21  kiyohara gxio_omap_mux_config(const struct omap_mux_conf mux_conf[])
    478  1.21  kiyohara {
    479  1.21  kiyohara #if defined(OVERO)
    480  1.21  kiyohara 	const vaddr_t ctrlmod_base = OVERO_L4_CORE_VBASE + 0x2000;
    481  1.21  kiyohara #elif defined(DUOVERO)
    482  1.21  kiyohara 	const vaddr_t ctrlmod_base = DUOVERO_L4_CM_VBASE;
    483  1.21  kiyohara #elif defined(PEPPER)
    484  1.21  kiyohara 	const vaddr_t ctrlmod_base = PEPPER_PRCM_VBASE + 0x10000;
    485  1.21  kiyohara #endif
    486  1.21  kiyohara 	int i;
    487  1.21  kiyohara 
    488  1.21  kiyohara 	for (i = 0; mux_conf[i].offset != -1; i++)
    489  1.21  kiyohara #if !defined(TI_AM335X)
    490  1.21  kiyohara 		ioreg16_write(ctrlmod_base + mux_conf[i].offset,
    491  1.21  kiyohara 		    mux_conf[i].value);
    492  1.21  kiyohara #else
    493  1.21  kiyohara 		ioreg_write(ctrlmod_base + mux_conf[i].offset,
    494  1.21  kiyohara 		    mux_conf[i].value);
    495  1.21  kiyohara #endif
    496  1.21  kiyohara }
    497  1.21  kiyohara 
    498  1.21  kiyohara static int
    499  1.21  kiyohara gxio_omap_mux_config_address(const char *name, unsigned long address,
    500  1.21  kiyohara 			     const struct omap_mux_conf mux_conf[],
    501  1.21  kiyohara 			     const struct omap_mux_conf not_mux_conf[])
    502  1.21  kiyohara {
    503  1.21  kiyohara 	extern struct cfdata cfdata[];
    504  1.21  kiyohara 	cfdata_t cf = &cfdata[0];
    505  1.21  kiyohara 
    506  1.21  kiyohara 	while (cf->cf_name != NULL) {
    507  1.21  kiyohara 		if (strcmp(name, cf->cf_name) == 0 &&
    508  1.21  kiyohara 		    address == cf->cf_loc[OBIOCF_ADDR]) {
    509  1.21  kiyohara 			gxio_omap_mux_config(mux_conf);
    510  1.21  kiyohara 			return 0;
    511  1.21  kiyohara 		}
    512  1.21  kiyohara 		cf++;
    513  1.21  kiyohara 	}
    514  1.21  kiyohara 
    515  1.21  kiyohara 	if (not_mux_conf == NULL)
    516  1.21  kiyohara 		return -1;
    517  1.21  kiyohara 
    518  1.21  kiyohara 	gxio_omap_mux_config(not_mux_conf);
    519  1.21  kiyohara 	return 0;
    520  1.21  kiyohara }
    521  1.21  kiyohara 
    522  1.21  kiyohara #if defined(OVERO)
    523  1.21  kiyohara #define gpio_reg_read		ioreg_read
    524  1.21  kiyohara #define gpio_reg_write		ioreg_write
    525  1.21  kiyohara #elif defined(DUOVERO) || defined(PEPPER)
    526  1.21  kiyohara #define gpio_reg_read(a)	ioreg_read((a) + GPIO_SIZE2)
    527  1.21  kiyohara #define gpio_reg_write(a, v)	ioreg_write((a) + GPIO_SIZE2, (v))
    528  1.21  kiyohara #endif
    529  1.21  kiyohara 
    530  1.21  kiyohara static const vaddr_t gpio_bases[] = {
    531  1.21  kiyohara #if defined(OVERO)
    532  1.21  kiyohara #define OVERO_GPIO_VBASE(n) ((n) == 1 ? BASE(WAKEUP, n) : BASE(PERIPHERAL, n))
    533  1.21  kiyohara #define GPIO(n)		GPIO ## n ## _BASE_3530
    534  1.21  kiyohara #define BASE(a, n) \
    535  1.21  kiyohara 	(OVERO_L4_ ## a ## _VBASE + (GPIO(n) - OMAP3530_L4_ ## a ## _BASE))
    536  1.21  kiyohara 
    537  1.21  kiyohara 	GPIO1_BASE_3530,
    538  1.21  kiyohara 	GPIO2_BASE_3530,
    539  1.21  kiyohara 	GPIO3_BASE_3530,
    540  1.21  kiyohara 	GPIO4_BASE_3530,
    541  1.21  kiyohara 	GPIO5_BASE_3530,
    542  1.21  kiyohara 	GPIO6_BASE_3530,
    543  1.21  kiyohara 
    544  1.21  kiyohara #elif defined(DUOVERO)
    545  1.21  kiyohara #define DUOVERO_GPIO_VBASE(n) ((n) == 1 ? BASE(WAKEUP, n) : BASE(PERIPHERAL, n))
    546  1.21  kiyohara #define GPIO(n)		GPIO ## n ## _BASE_4430
    547  1.21  kiyohara #define BASE(a, n) \
    548  1.21  kiyohara 	(DUOVERO_L4_ ## a ## _VBASE + (GPIO(n) - OMAP4430_L4_ ## a ## _BASE))
    549  1.21  kiyohara 
    550  1.21  kiyohara 	DUOVERO_GPIO_VBASE(1),
    551  1.21  kiyohara 	DUOVERO_GPIO_VBASE(2),
    552  1.21  kiyohara 	DUOVERO_GPIO_VBASE(3),
    553  1.21  kiyohara 	DUOVERO_GPIO_VBASE(4),
    554  1.21  kiyohara 	DUOVERO_GPIO_VBASE(5),
    555  1.21  kiyohara 
    556  1.21  kiyohara #elif defined(PEPPER)
    557  1.21  kiyohara #define PEPPER_GPIO_VBASE(n) ((n) == 0 ? WAKEUP(n) : PERIPHERAL(n))
    558  1.21  kiyohara #define GPIO(n)		GPIO ## n ## _BASE_TI_AM335X
    559  1.21  kiyohara #define WAKEUP(n)	(PEPPER_PRCM_VBASE + (GPIO(n) - OMAP2_CM_BASE))
    560  1.21  kiyohara #define PERIPHERAL(n) \
    561  1.21  kiyohara 	(PEPPER_L4_PERIPHERAL_VBASE + (GPIO(n) - TI_AM335X_L4_PERIPHERAL_BASE))
    562  1.21  kiyohara 
    563  1.21  kiyohara 	PEPPER_GPIO_VBASE(0),
    564  1.21  kiyohara 	PEPPER_GPIO_VBASE(1),
    565  1.21  kiyohara 	PEPPER_GPIO_VBASE(2),
    566  1.21  kiyohara 	PEPPER_GPIO_VBASE(3),
    567  1.21  kiyohara #endif
    568  1.21  kiyohara };
    569  1.21  kiyohara 
    570  1.21  kiyohara static void
    571  1.21  kiyohara gxio_omap_gpio_config(const struct omap_gpio_conf gpio_conf[])
    572  1.21  kiyohara {
    573  1.21  kiyohara 	vaddr_t gpio_base;
    574  1.21  kiyohara 	int mask, i;
    575  1.21  kiyohara 
    576  1.21  kiyohara 	for (i = 0; gpio_conf[i].pin != -1; i++) {
    577  1.21  kiyohara 		gpio_base = gpio_bases[gpio_conf[i].pin / 32];
    578  1.21  kiyohara 		mask = 1 << (gpio_conf[i].pin % 32);
    579  1.21  kiyohara 		switch (gpio_conf[i].conf) {
    580  1.21  kiyohara 		case conf_input:
    581  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_OE,
    582  1.21  kiyohara 			    ioreg_read(gpio_base + GPIO_OE) | mask);
    583  1.21  kiyohara 			break;
    584  1.21  kiyohara 		case conf_output_0:
    585  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_OE,
    586  1.21  kiyohara 			    ioreg_read(gpio_base + GPIO_OE) | ~mask);
    587  1.21  kiyohara #if 0
    588  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_CLEARDATAOUT, mask);
    589  1.21  kiyohara #else
    590  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_DATAOUT,
    591  1.21  kiyohara 			    ioreg_read(gpio_base + GPIO_DATAOUT) & ~mask);
    592  1.21  kiyohara #endif
    593  1.21  kiyohara 			break;
    594  1.21  kiyohara 		case conf_output_1:
    595  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_OE,
    596  1.21  kiyohara 			    ioreg_read(gpio_base + GPIO_OE) | ~mask);
    597  1.21  kiyohara #if 0
    598  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_SETDATAOUT, mask);
    599  1.21  kiyohara #else
    600  1.21  kiyohara 			ioreg_write(gpio_base + GPIO_DATAOUT,
    601  1.21  kiyohara 			    ioreg_read(gpio_base + GPIO_DATAOUT) | mask);
    602  1.21  kiyohara #endif
    603  1.21  kiyohara 			break;
    604  1.21  kiyohara 		}
    605  1.21  kiyohara 	}
    606  1.21  kiyohara }
    607  1.21  kiyohara 
    608  1.21  kiyohara void
    609  1.21  kiyohara gxio_omap_gpio_write(int pin, int val)
    610  1.21  kiyohara {
    611  1.21  kiyohara 	vaddr_t gpio_base;
    612  1.21  kiyohara 	int mask;
    613  1.21  kiyohara 
    614  1.21  kiyohara 	KASSERT(pin / 32 < __arraycount(gpio_bases));
    615  1.21  kiyohara 
    616  1.21  kiyohara 	gpio_base = gpio_bases[pin / 32];
    617  1.21  kiyohara 	mask = 1 << (pin % 32);
    618  1.21  kiyohara 	if (val == 0)
    619  1.21  kiyohara 		ioreg_write(gpio_base + GPIO_CLEARDATAOUT, mask);
    620  1.21  kiyohara 	else
    621  1.21  kiyohara 		ioreg_write(gpio_base + GPIO_SETDATAOUT, mask);
    622  1.21  kiyohara }
    623  1.21  kiyohara 
    624  1.21  kiyohara /*
    625  1.21  kiyohara  * configure for MUX, GPIO.
    626  1.21  kiyohara  */
    627  1.21  kiyohara void
    628  1.21  kiyohara gxio_config(void)
    629  1.21  kiyohara {
    630  1.21  kiyohara 	const struct omap_mux_conf *mux_conf[] = {
    631  1.21  kiyohara #if defined(OVERO)
    632  1.21  kiyohara 		overo_mux_i2c3_conf,
    633  1.21  kiyohara 		overo_mux_mmchs2_conf,
    634  1.21  kiyohara 		overo_mux_wireless_conf,
    635  1.21  kiyohara #elif defined(DUOVERO)
    636  1.21  kiyohara 		duovero_mux_led_conf,
    637  1.21  kiyohara 		duovero_mux_button_conf,
    638  1.21  kiyohara #elif defined(PEPPER)
    639  1.21  kiyohara 		pepper_mux_led_conf,
    640  1.21  kiyohara 		pepper_mux_button_conf,
    641  1.21  kiyohara 		pepper_mux_mmchs3_conf,
    642  1.21  kiyohara 		pepper_mux_audio_codec_conf,
    643  1.21  kiyohara #endif
    644  1.21  kiyohara 	};
    645  1.21  kiyohara 	const struct omap_gpio_conf gpio_conf[] = {
    646  1.21  kiyohara #if defined(OVERO)
    647  1.21  kiyohara 		{  16, conf_output_0 },		/* Wireless: #Reset */
    648  1.21  kiyohara #elif defined(PEPPER)
    649  1.21  kiyohara 		{  48, conf_output_0 },		/* Audio Codec: #Reset */
    650  1.21  kiyohara #endif
    651  1.21  kiyohara 		{ -1 }
    652  1.21  kiyohara 	};
    653  1.21  kiyohara 	int i;
    654  1.21  kiyohara 
    655  1.21  kiyohara 	for (i = 0; i < __arraycount(mux_conf); i++)
    656  1.21  kiyohara 		gxio_omap_mux_config(mux_conf[i]);
    657  1.21  kiyohara 	gxio_omap_gpio_config(gpio_conf);
    658  1.21  kiyohara }
    659  1.21  kiyohara #endif
    660   1.3  kiyohara 
    661   1.4  kiyohara void
    662   1.6  kiyohara gxio_config_expansion(char *expansion)
    663   1.4  kiyohara {
    664  1.21  kiyohara 	int i, d, s;
    665   1.4  kiyohara 
    666   1.6  kiyohara 	if (expansion == NULL) {
    667  1.16  kiyohara 		printf("not specified 'expansion=' in the boot args.\n");
    668  1.21  kiyohara 		s = -1;
    669  1.21  kiyohara 	} else {
    670  1.21  kiyohara 		for (i = 0; gxioconflist[i].name != NULL; i++)
    671  1.21  kiyohara 			if (strncasecmp(gxioconflist[i].name, expansion,
    672  1.21  kiyohara 					strlen(gxioconflist[i].name) + 1) == 0)
    673  1.21  kiyohara 				break;
    674  1.21  kiyohara 		if (gxioconflist[i].name == NULL)
    675  1.21  kiyohara 			printf("unknown expansion specified: %s\n", expansion);
    676  1.21  kiyohara 		s = i;
    677  1.21  kiyohara 	}
    678  1.21  kiyohara #ifdef GXIO_DEFAULT_EXPANSION
    679  1.21  kiyohara 	for (i = 0; gxioconflist[i].name != NULL; i++)
    680  1.21  kiyohara 		if (strncasecmp(gxioconflist[i].name, GXIO_DEFAULT_EXPANSION,
    681  1.21  kiyohara 					strlen(gxioconflist[i].name) + 1) == 0)
    682  1.21  kiyohara 			break;
    683  1.21  kiyohara 	d = i;
    684  1.21  kiyohara #else
    685  1.21  kiyohara 	d = -1;
    686  1.21  kiyohara #endif
    687  1.21  kiyohara 	printf("supported expansions:\n");
    688  1.21  kiyohara 	for (i = 0; gxioconflist[i].name != NULL; i++)
    689  1.21  kiyohara 		printf("  %s%s\n",
    690  1.21  kiyohara 		    gxioconflist[i].name,
    691  1.21  kiyohara 		    i == d ? " (DEFAULT)" : "");
    692  1.21  kiyohara 
    693  1.21  kiyohara 	if (s < 0 || gxioconflist[i].name == NULL) {
    694  1.10  kiyohara #ifdef GXIO_DEFAULT_EXPANSION
    695  1.11  kiyohara 		expansion = __UNCONST(GXIO_DEFAULT_EXPANSION);
    696  1.10  kiyohara #else
    697  1.10  kiyohara 		return;
    698   1.6  kiyohara #endif
    699   1.6  kiyohara 	}
    700   1.4  kiyohara 
    701  1.21  kiyohara #if defined(PEPPER)
    702  1.21  kiyohara 	if (s < 0) {
    703  1.21  kiyohara 		struct pepper_board_id {
    704  1.21  kiyohara 			unsigned int device_vendor;
    705  1.21  kiyohara #define GUMSTIX_PEPPER          0x30000200	/* 1st gen */
    706  1.21  kiyohara #define GUMSTIX_PEPPER_DVI      0x31000200	/* DVI and newer */
    707  1.21  kiyohara 			unsigned char revision;
    708  1.21  kiyohara 			unsigned char content;
    709  1.21  kiyohara 			char fab_revision[8];
    710  1.21  kiyohara 			char env_var[16];
    711  1.21  kiyohara 			char env_setting[64];
    712  1.21  kiyohara 		} id;
    713  1.21  kiyohara 		const vaddr_t i2c_base = PEPPER_PRCM_VBASE + 0xb000;
    714  1.21  kiyohara 		const uint8_t eeprom = 0x50;
    715  1.21  kiyohara 		const uint8_t len = sizeof(id);
    716  1.21  kiyohara 		int rv;
    717  1.21  kiyohara 
    718  1.21  kiyohara 		rv = read_i2c_device(i2c_base, eeprom, 0x00, len, (void *)&id);
    719  1.21  kiyohara 		if (rv == 0)
    720  1.21  kiyohara 			if (id.device_vendor == GUMSTIX_PEPPER) {
    721  1.21  kiyohara 				printf("configure auto detected expansion"
    722  1.21  kiyohara 				    " (pepper)\n");
    723  1.21  kiyohara 				pepper_config();
    724  1.21  kiyohara 				return;
    725  1.21  kiyohara 			}
    726  1.21  kiyohara 	}
    727  1.21  kiyohara #endif
    728   1.1  kiyohara 
    729  1.21  kiyohara 	printf("configure %s expansion (%s)\n",
    730  1.21  kiyohara 	    (s < 0 || gxioconflist[i].name == NULL) ? "default" : "specified",
    731  1.21  kiyohara 	    expansion);
    732  1.21  kiyohara 	gxioconflist[(s < 0 || gxioconflist[i].name == NULL) ? d : s].config();
    733   1.3  kiyohara }
    734   1.1  kiyohara 
    735   1.1  kiyohara 
    736  1.16  kiyohara #if defined(GUMSTIX)
    737  1.16  kiyohara 
    738   1.1  kiyohara static void
    739   1.9    cegger basix_config(void)
    740   1.6  kiyohara {
    741   1.6  kiyohara 
    742   1.6  kiyohara 	pxa2x0_gpio_set_function(8, GPIO_ALT_FN_1_OUT);		/* MMCCS0 */
    743   1.6  kiyohara 	pxa2x0_gpio_set_function(53, GPIO_ALT_FN_1_OUT);	/* MMCCLK */
    744   1.6  kiyohara #if 0
    745   1.6  kiyohara 	/* this configuration set by gxmci.c::pxamci_attach() */
    746   1.6  kiyohara 	pxa2x0_gpio_set_function(11, GPIO_IN);			/* nSD_DETECT */
    747   1.6  kiyohara 	pxa2x0_gpio_set_function(22, GPIO_IN);			/* nSD_WP */
    748   1.6  kiyohara #endif
    749   1.6  kiyohara }
    750   1.6  kiyohara 
    751   1.6  kiyohara static void
    752   1.9    cegger cfstix_config(void)
    753   1.1  kiyohara {
    754   1.1  kiyohara 	u_int gpio, npoe_fn;
    755  1.10  kiyohara #if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
    756  1.10  kiyohara 	int bvd = (CPU_IS_PXA250) ? 4 : 111;
    757  1.10  kiyohara #else
    758  1.10  kiyohara #if defined(CPU_XSCALE_PXA270)
    759  1.10  kiyohara 	const int bvd = 111;
    760  1.10  kiyohara #else
    761  1.10  kiyohara 	const int bvd = 4;
    762  1.10  kiyohara #endif
    763  1.10  kiyohara #endif
    764  1.10  kiyohara 
    765  1.10  kiyohara 	if (CPU_IS_PXA250) {
    766  1.10  kiyohara 		gxpcic_slot_irqs[0].valid = 1;
    767  1.10  kiyohara 		gxpcic_slot_irqs[0].cd = 11;
    768  1.10  kiyohara 		gxpcic_slot_irqs[0].prdy = 26;
    769  1.10  kiyohara 		gxpcic_gpio_reset = 8;
    770  1.10  kiyohara 	} else {
    771  1.10  kiyohara 		gxpcic_slot_irqs[0].valid = 1;
    772  1.10  kiyohara 		gxpcic_slot_irqs[0].cd = 104;
    773  1.10  kiyohara 		gxpcic_slot_irqs[0].prdy = 96;
    774  1.10  kiyohara 		gxpcic_gpio_reset = 97;
    775  1.10  kiyohara 	}
    776   1.1  kiyohara 
    777   1.4  kiyohara #if 1
    778  1.10  kiyohara 	/* PCD/PRDY set by pxa2x0_pcic.c::pxapcic_attach_common() */
    779   1.4  kiyohara #else
    780   1.4  kiyohara 	pxa2x0_gpio_set_function(11, GPIO_IN);		/* PCD1 */
    781   1.4  kiyohara 	pxa2x0_gpio_set_function(26, GPIO_IN);		/* PRDY1/~IRQ1 */
    782   1.4  kiyohara #endif
    783  1.10  kiyohara 	pxa2x0_gpio_set_function(bvd, GPIO_IN); 	/* BVD1/~STSCHG1 */
    784   1.1  kiyohara 
    785   1.1  kiyohara 	for (gpio = 48, npoe_fn = 0; gpio <= 53 ; gpio++)
    786   1.1  kiyohara 		npoe_fn |= pxa2x0_gpio_get_function(gpio);
    787   1.1  kiyohara 	npoe_fn &= GPIO_SET;
    788   1.1  kiyohara 
    789   1.1  kiyohara 	pxa2x0_gpio_set_function(48, GPIO_ALT_FN_2_OUT | npoe_fn); /* nPOE */
    790   1.1  kiyohara 	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
    791   1.1  kiyohara 	pxa2x0_gpio_set_function(50, GPIO_ALT_FN_2_OUT);	/* nPIOR */
    792   1.1  kiyohara 	pxa2x0_gpio_set_function(51, GPIO_ALT_FN_2_OUT);	/* nPIOW */
    793  1.10  kiyohara 	if (CPU_IS_PXA250) {
    794  1.10  kiyohara 		pxa2x0_gpio_set_function(52, GPIO_ALT_FN_2_OUT); /* nPCE1 */
    795  1.10  kiyohara 		pxa2x0_gpio_set_function(53, GPIO_ALT_FN_2_OUT); /* nPCE2 */
    796  1.10  kiyohara 		pxa2x0_gpio_set_function(54, GPIO_ALT_FN_2_OUT); /* pSKTSEL */
    797  1.10  kiyohara 	} else {
    798  1.10  kiyohara 		pxa2x0_gpio_set_function(102, GPIO_ALT_FN_1_OUT); /* nPCE1 */
    799  1.10  kiyohara 		pxa2x0_gpio_set_function(105, GPIO_ALT_FN_1_OUT); /* nPCE2 */
    800  1.10  kiyohara 		pxa2x0_gpio_set_function(79, GPIO_ALT_FN_1_OUT);  /* pSKTSEL */
    801  1.10  kiyohara 	}
    802   1.1  kiyohara 	pxa2x0_gpio_set_function(55, GPIO_ALT_FN_2_OUT);	/* nPREG */
    803   1.1  kiyohara 	pxa2x0_gpio_set_function(56, GPIO_ALT_FN_1_IN);		/* nPWAIT */
    804   1.1  kiyohara 	pxa2x0_gpio_set_function(57, GPIO_ALT_FN_1_IN);		/* nIOIS16 */
    805   1.1  kiyohara }
    806   1.1  kiyohara 
    807   1.1  kiyohara static void
    808   1.9    cegger etherstix_config(void)
    809   1.1  kiyohara {
    810  1.10  kiyohara 	extern struct cfdata cfdata[];
    811  1.10  kiyohara #if defined(CPU_XSCALE_PXA270) && defined(CPU_XSCALE_PXA250)
    812  1.10  kiyohara 	int rst = (CPU_IS_PXA250) ? 80 : 32;
    813  1.10  kiyohara 	int irq = (CPU_IS_PXA250) ? 36 : 99;
    814  1.10  kiyohara #else
    815  1.10  kiyohara #if defined(CPU_XSCALE_PXA270)
    816  1.10  kiyohara 	const int rst = 32, irq = 99;
    817  1.10  kiyohara #else
    818  1.10  kiyohara 	const int rst = 80, irq = 36;
    819  1.10  kiyohara #endif
    820  1.10  kiyohara #endif
    821  1.10  kiyohara 	int i;
    822   1.1  kiyohara 
    823   1.1  kiyohara 	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
    824   1.1  kiyohara 	pxa2x0_gpio_set_function(15, GPIO_ALT_FN_2_OUT);	/* nCS 1 */
    825  1.10  kiyohara 	pxa2x0_gpio_set_function(rst, GPIO_OUT | GPIO_SET);	/* RESET 1 */
    826   1.1  kiyohara 	delay(1);
    827  1.10  kiyohara 	pxa2x0_gpio_set_function(rst, GPIO_OUT | GPIO_CLR);
    828   1.1  kiyohara 	delay(50000);
    829  1.10  kiyohara 
    830  1.10  kiyohara 	for (i = 0; cfdata[i].cf_name != NULL; i++)
    831  1.10  kiyohara 		if (strcmp(cfdata[i].cf_name, "sm") == 0 &&
    832  1.10  kiyohara 		    strcmp(cfdata[i].cf_atname, "sm_gxio") == 0 &&
    833  1.10  kiyohara 		    cfdata[i].cf_loc[GXIOCF_ADDR] == 0x04000300 &&
    834  1.10  kiyohara 		    cfdata[i].cf_loc[GXIOCF_GPIRQ] == GXIOCF_GPIRQ_DEFAULT)
    835  1.10  kiyohara 			cfdata[i].cf_loc[GXIOCF_GPIRQ] = irq;
    836   1.1  kiyohara }
    837   1.1  kiyohara 
    838   1.1  kiyohara static void
    839   1.9    cegger netcf_config(void)
    840   1.1  kiyohara {
    841   1.1  kiyohara 
    842   1.4  kiyohara 	etherstix_config();
    843   1.4  kiyohara 	cfstix_config();
    844  1.14  kiyohara }
    845  1.14  kiyohara 
    846  1.14  kiyohara static void
    847  1.14  kiyohara netcf_vx_config(void)
    848  1.14  kiyohara {
    849  1.14  kiyohara 
    850  1.14  kiyohara 	/*
    851  1.14  kiyohara 	 * XXXX: More power is necessary for NIC and USB???
    852  1.14  kiyohara 	 * (no document.  from Linux)
    853  1.14  kiyohara 	 */
    854  1.14  kiyohara 
    855  1.14  kiyohara 	pxa2x0_gpio_set_function(27, GPIO_IN);
    856  1.14  kiyohara 	pxa2x0_gpio_set_function(107, GPIO_OUT | GPIO_CLR);
    857  1.14  kiyohara 	pxa2x0_gpio_set_function(118, GPIO_ALT_FN_1_IN | GPIO_CLR);
    858  1.14  kiyohara 
    859  1.14  kiyohara 	etherstix_config();
    860  1.14  kiyohara 	cfstix_config();
    861  1.10  kiyohara 	if (CPU_IS_PXA270) {
    862  1.10  kiyohara 		/* Overwrite */
    863  1.10  kiyohara 		gxpcic_slot_irqs[0].cd = 104;
    864  1.10  kiyohara 		gxpcic_slot_irqs[0].prdy = 109;
    865  1.10  kiyohara 		gxpcic_gpio_reset = 110;
    866  1.10  kiyohara 	};
    867   1.1  kiyohara }
    868   1.1  kiyohara 
    869   1.1  kiyohara static void
    870   1.9    cegger netduommc_config(void)
    871   1.3  kiyohara {
    872   1.3  kiyohara 
    873   1.4  kiyohara 	netduo_config();
    874   1.6  kiyohara 	basix_config();
    875   1.3  kiyohara }
    876   1.3  kiyohara 
    877   1.3  kiyohara static void
    878   1.9    cegger netduo_config(void)
    879   1.1  kiyohara {
    880   1.1  kiyohara 
    881   1.4  kiyohara 	etherstix_config();
    882   1.1  kiyohara 
    883   1.1  kiyohara 	pxa2x0_gpio_set_function(78, GPIO_ALT_FN_2_OUT);	/* nCS 2 */
    884   1.1  kiyohara 	pxa2x0_gpio_set_function(52, GPIO_OUT | GPIO_SET);	/* RESET 2 */
    885   1.1  kiyohara 	delay(1);
    886   1.1  kiyohara 	pxa2x0_gpio_set_function(52, GPIO_OUT | GPIO_CLR);
    887   1.1  kiyohara 	delay(50000);
    888   1.1  kiyohara }
    889   1.1  kiyohara 
    890   1.1  kiyohara static void
    891  1.10  kiyohara netmicrosd_config(void)
    892  1.10  kiyohara {
    893  1.10  kiyohara 
    894  1.10  kiyohara 	/* MicroSD(mci) always configure on PXA270 */
    895  1.10  kiyohara 
    896  1.10  kiyohara 	pxa2x0_gpio_set_function(49, GPIO_ALT_FN_2_OUT);	/* nPWE */
    897  1.10  kiyohara 	pxa2x0_gpio_set_function(15, GPIO_ALT_FN_2_OUT);	/* nCS 1 */
    898  1.10  kiyohara 	pxa2x0_gpio_set_function(107, GPIO_OUT | GPIO_CLR);	/* RESET 1 */
    899  1.10  kiyohara 	delay(hz / 2);
    900  1.10  kiyohara 	pxa2x0_gpio_set_function(107, GPIO_OUT | GPIO_SET);
    901  1.10  kiyohara 	delay(50000);
    902  1.10  kiyohara }
    903  1.10  kiyohara 
    904  1.10  kiyohara static void
    905  1.10  kiyohara netwifimicrosd_config(void)
    906  1.10  kiyohara {
    907  1.10  kiyohara 
    908  1.10  kiyohara 	netmicrosd_config();
    909  1.10  kiyohara 
    910  1.10  kiyohara 	cfstix_config();
    911  1.10  kiyohara 	/* However use pxamci. */
    912  1.10  kiyohara 	pxa2x0_gpio_set_function(111, GPIO_CLR | GPIO_ALT_FN_1_IN);
    913  1.12  kiyohara 	/* Power to Marvell 88W8385 */
    914  1.10  kiyohara 	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
    915  1.10  kiyohara }
    916  1.10  kiyohara 
    917  1.10  kiyohara static void
    918   1.9    cegger netmmc_config(void)
    919   1.1  kiyohara {
    920   1.1  kiyohara 
    921   1.4  kiyohara 	etherstix_config();
    922   1.6  kiyohara 	basix_config();
    923   1.1  kiyohara }
    924   1.4  kiyohara 
    925   1.4  kiyohara static void
    926  1.10  kiyohara wifistix_config(void)
    927  1.10  kiyohara {
    928  1.10  kiyohara 
    929  1.10  kiyohara 	cfstix_config();
    930  1.10  kiyohara 
    931  1.12  kiyohara 	/* Power to Marvell 88W8385 */
    932  1.10  kiyohara 	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
    933  1.10  kiyohara }
    934  1.10  kiyohara 
    935  1.10  kiyohara static void
    936   1.9    cegger wifistix_cf_config(void)
    937   1.4  kiyohara {
    938   1.4  kiyohara 
    939  1.10  kiyohara 	gxpcic_slot_irqs[1].valid = 1;
    940  1.10  kiyohara 	gxpcic_slot_irqs[1].cd = 36;
    941  1.10  kiyohara 	gxpcic_slot_irqs[1].prdy = 27;
    942  1.10  kiyohara 
    943   1.4  kiyohara #if 1
    944   1.6  kiyohara 	/* this configuration set by pxa2x0_pcic.c::pxapcic_attach_common() */
    945   1.4  kiyohara #else
    946   1.4  kiyohara 	pxa2x0_gpio_set_function(36, GPIO_IN);		/* PCD2 */
    947   1.4  kiyohara 	pxa2x0_gpio_set_function(27, GPIO_IN);		/* PRDY2/~IRQ2 */
    948   1.4  kiyohara #endif
    949   1.4  kiyohara 	pxa2x0_gpio_set_function(18, GPIO_IN); 		/* BVD2/~STSCHG2 */
    950   1.4  kiyohara 
    951   1.4  kiyohara 	cfstix_config();
    952  1.10  kiyohara 
    953  1.12  kiyohara 	/* Power to Marvell 88W8385 */
    954  1.10  kiyohara 	pxa2x0_gpio_set_function(80, GPIO_OUT | GPIO_SET);
    955   1.4  kiyohara }
    956  1.16  kiyohara 
    957  1.16  kiyohara #elif defined(OVERO)
    958  1.16  kiyohara 
    959  1.16  kiyohara static void
    960  1.16  kiyohara eth0_config(void)
    961  1.16  kiyohara {
    962  1.16  kiyohara 	/*
    963  1.16  kiyohara 	 * ETH0 connects via CS5.  It use GPIO 176 for IRQ.
    964  1.20  kiyohara 	 * Also GPIO 64 is NRESET.
    965  1.16  kiyohara 	 */
    966  1.16  kiyohara 
    967  1.21  kiyohara 	smsh_config(NULL, 176, 64);
    968  1.21  kiyohara }
    969  1.16  kiyohara 
    970  1.21  kiyohara static void
    971  1.21  kiyohara eth1_config(void)
    972  1.21  kiyohara {
    973  1.21  kiyohara 	struct omap_mux_conf eth1_mux_conf[] = {
    974  1.21  kiyohara 		{ 0x0d2, MUXMODE(4) | INPUTENABLE },
    975  1.21  kiyohara 		{ -1 }
    976  1.21  kiyohara 	};
    977  1.16  kiyohara 
    978  1.16  kiyohara 	/*
    979  1.21  kiyohara 	 * ETH1 connects via CS4.  It use GPIO 65 for IRQ.
    980  1.16  kiyohara 	 */
    981  1.21  kiyohara 
    982  1.21  kiyohara 	smsh_config(eth1_mux_conf, 65, 64);
    983  1.16  kiyohara }
    984  1.16  kiyohara 
    985  1.16  kiyohara static void
    986  1.21  kiyohara dvi_config(void)
    987  1.21  kiyohara {
    988  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_dvi_conf[] = {
    989  1.21  kiyohara 		{ 0x0d4, MUXMODE(0) },				/* dss_pclk */
    990  1.21  kiyohara 		{ 0x0d6, MUXMODE(0) },				/* dss_pclk */
    991  1.21  kiyohara 		{ 0x0d8, MUXMODE(0) },				/* dss_pclk */
    992  1.21  kiyohara 		{ 0x0da, MUXMODE(0) },				/* dss_pclk */
    993  1.21  kiyohara 		{ 0x0dc, MUXMODE(0) },				/* dss_pclk */
    994  1.21  kiyohara 		{ 0x0de, MUXMODE(0) },				/* dss_pclk */
    995  1.21  kiyohara 		{ 0x0e0, MUXMODE(0) },				/* dss_pclk */
    996  1.21  kiyohara 		{ 0x0e2, MUXMODE(0) },				/* dss_pclk */
    997  1.21  kiyohara 		{ 0x0e4, MUXMODE(0) },				/* dss_pclk */
    998  1.21  kiyohara 		{ 0x0e6, MUXMODE(0) },				/* dss_pclk */
    999  1.21  kiyohara 		{ 0x0e8, MUXMODE(0) },				/* dss_pclk */
   1000  1.21  kiyohara 		{ 0x0ea, MUXMODE(0) },				/* dss_pclk */
   1001  1.21  kiyohara 		{ 0x0ec, MUXMODE(0) },				/* dss_pclk */
   1002  1.21  kiyohara 		{ 0x0ee, MUXMODE(0) },				/* dss_pclk */
   1003  1.21  kiyohara 		{ 0x0f0, MUXMODE(0) },				/* dss_pclk */
   1004  1.21  kiyohara 		{ 0x0f2, MUXMODE(0) },				/* dss_pclk */
   1005  1.21  kiyohara 		{ 0x0f4, MUXMODE(0) },				/* dss_pclk */
   1006  1.21  kiyohara 		{ 0x0f6, MUXMODE(0) },				/* dss_pclk */
   1007  1.21  kiyohara 		{ 0x0f8, MUXMODE(0) },				/* dss_pclk */
   1008  1.21  kiyohara 		{ 0x0fa, MUXMODE(0) },				/* dss_pclk */
   1009  1.21  kiyohara 		{ 0x0fc, MUXMODE(0) },				/* dss_pclk */
   1010  1.21  kiyohara 		{ 0x0fe, MUXMODE(0) },				/* dss_pclk */
   1011  1.21  kiyohara 		{ 0x100, MUXMODE(0) },				/* dss_pclk */
   1012  1.21  kiyohara 		{ 0x102, MUXMODE(0) },				/* dss_pclk */
   1013  1.21  kiyohara 		{ 0x104, MUXMODE(0) },				/* dss_pclk */
   1014  1.21  kiyohara 		{ 0x106, MUXMODE(0) },				/* dss_pclk */
   1015  1.21  kiyohara 		{ 0x108, MUXMODE(0) },				/* dss_pclk */
   1016  1.21  kiyohara 		{ 0x10a, MUXMODE(0) },				/* dss_pclk */
   1017  1.21  kiyohara 		{ -1 }
   1018  1.21  kiyohara 	};
   1019  1.21  kiyohara 
   1020  1.21  kiyohara 	gxio_omap_mux_config(overo_mux_dvi_conf);
   1021  1.21  kiyohara }
   1022  1.21  kiyohara 
   1023  1.21  kiyohara static void
   1024  1.21  kiyohara lcd_config(char type)
   1025  1.16  kiyohara {
   1026  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_mcspi1_conf[] = {
   1027  1.21  kiyohara 		{ 0x1c8, MUXMODE(0) | INPUTENABLE },		/* mcspi1_clk */
   1028  1.21  kiyohara 		{ 0x1ca, MUXMODE(0) | INPUTENABLE },		/* mcspi1_simo*/
   1029  1.21  kiyohara 		{ 0x1cc, MUXMODE(0) | INPUTENABLE },		/* mcspi1_somi*/
   1030  1.21  kiyohara 		{ 0x1ce, MUXMODE(0) | INPUTENABLE },		/* mcspi1_cs0 */
   1031  1.21  kiyohara 		{ 0x1d0, MUXMODE(0) | INPUTENABLE },		/* mcspi1_cs1 */
   1032  1.21  kiyohara 		{ -1 }
   1033  1.21  kiyohara 	};
   1034  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_ads7846_conf[] = {
   1035  1.21  kiyohara 		{ 0x138,			/* gpio_114: NPENIRQ */
   1036  1.21  kiyohara 		  MUXMODE(4) | PULLUDENABLE | INPUTENABLE },
   1037  1.21  kiyohara 		{ -1 }
   1038  1.21  kiyohara 	};
   1039  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_lcd_conf[] = {
   1040  1.21  kiyohara 		{ 0x174, MUXMODE(4) },		/* gpio_144: DISPLAY_EN */
   1041  1.21  kiyohara 		{ 0x176, MUXMODE(4) },		/* gpio_145: Brightness */
   1042  1.21  kiyohara 		{ -1 }
   1043  1.21  kiyohara 	};
   1044  1.16  kiyohara 
   1045  1.21  kiyohara 	static const struct omap_gpio_conf overo_gpio_lcd_conf[] = {
   1046  1.21  kiyohara 		{ 144, conf_output_0 },		/* DISPLAY_EN */
   1047  1.21  kiyohara 		{ 145, conf_output_0 },		/* Brightness */
   1048  1.21  kiyohara 		{ -1 }
   1049  1.21  kiyohara 	};
   1050  1.16  kiyohara 
   1051  1.21  kiyohara 	dvi_config();
   1052  1.21  kiyohara 	if (type != 'C') {
   1053  1.21  kiyohara 		gxio_omap_mux_config(overo_mux_mcspi1_conf);
   1054  1.21  kiyohara 		gxio_omap_mux_config(overo_mux_ads7846_conf);
   1055  1.16  kiyohara 	}
   1056  1.21  kiyohara 	gxio_omap_mux_config(overo_mux_lcd_conf);
   1057  1.16  kiyohara 
   1058  1.21  kiyohara 	gxio_omap_gpio_config(overo_gpio_lcd_conf);
   1059  1.21  kiyohara }
   1060  1.16  kiyohara 
   1061  1.21  kiyohara enum {
   1062  1.21  kiyohara 	uart1_if_exists = 0,
   1063  1.21  kiyohara 	force_uart1
   1064  1.21  kiyohara };
   1065  1.21  kiyohara static void
   1066  1.21  kiyohara header_40pin_config(int uart1)
   1067  1.21  kiyohara {
   1068  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_40pin_header_conf[] = {
   1069  1.21  kiyohara 		/*
   1070  1.21  kiyohara 		 *  1: GND
   1071  1.21  kiyohara 		 *  2: VCC_3.3
   1072  1.21  kiyohara 		 *  3: GPIO171_SPI1_CLK
   1073  1.21  kiyohara 		 *  4: GPIO114_SPI1_NIRQ
   1074  1.21  kiyohara 		 *  5: GPIO172_SPI1_MOSI
   1075  1.21  kiyohara 		 *  6: GPIO174_SPI1_CS0
   1076  1.21  kiyohara 		 *  7: GPIO173_SPI1_MISO
   1077  1.21  kiyohara 		 *  8: GPIO175_SPI1_CS1
   1078  1.21  kiyohara 		 *  9: GPIO151_RXD1
   1079  1.21  kiyohara 		 * 10: GPIO148_TXD1
   1080  1.21  kiyohara 		 * 11: SYS_EN
   1081  1.21  kiyohara 		 * 12: VBACKUP
   1082  1.21  kiyohara 		 * 13: GPIO0_WAKEUP
   1083  1.21  kiyohara 		 * 14: POWERON
   1084  1.21  kiyohara 		 * 15: GND
   1085  1.21  kiyohara 		 * 16: VCC_1.8
   1086  1.21  kiyohara 		 * 17: GPIO128_GPS_PPS
   1087  1.21  kiyohara 		 * 18: GPIO127_TS_IRQ
   1088  1.21  kiyohara 		 * 19: GPIO170_HDQ_1WIRE
   1089  1.21  kiyohara 		 * 20: GPIO163_IR_CTS3
   1090  1.21  kiyohara 		 * 21: GPIO165_IR_RXD3	(console)
   1091  1.21  kiyohara 		 * 22: GPIO166_IR_TXD3	(console)
   1092  1.21  kiyohara 		 * 23: GPIO184_SCL3	(system eeprom)
   1093  1.21  kiyohara 		 * 24: GPIO185_SDA3	(system eeprom)
   1094  1.21  kiyohara 		 * 25: GND
   1095  1.21  kiyohara 		 * 26: VCC_1.8
   1096  1.21  kiyohara 		 * 27: GPIO146_PWM11
   1097  1.21  kiyohara 		 * 28: GPIO145_PWM10
   1098  1.21  kiyohara 		 * 29: GPIO147_PWM8
   1099  1.21  kiyohara 		 * 30: GPIO144_PWM9
   1100  1.21  kiyohara 		 * 31: PWM0 (TPS65950)
   1101  1.21  kiyohara 		 * 32: PWM1 (TPS65950)
   1102  1.21  kiyohara 		 * 33: ADCIN7 (TPS65950)
   1103  1.21  kiyohara 		 * 34: ADCIN2 (TPS65950)
   1104  1.21  kiyohara 		 * 35: ADCIN6 (TPS65950)
   1105  1.21  kiyohara 		 * 36: ADCIN5 (TPS65950)
   1106  1.21  kiyohara 		 * 37: AGND (TPS65950)
   1107  1.21  kiyohara 		 * 38: ADCIN3 (TPS65950)
   1108  1.21  kiyohara 		 * 39: ADCIN4 (TPS65950)
   1109  1.21  kiyohara 		 * 40: VIN (TPS65950)
   1110  1.21  kiyohara 		 */
   1111  1.21  kiyohara 
   1112  1.21  kiyohara 		{ 0x152, MUXMODE(4) | INPUTENABLE },		/* gpio_127 */
   1113  1.21  kiyohara 		{ 0x154, MUXMODE(4) | INPUTENABLE },		/* gpio_128 */
   1114  1.21  kiyohara 		{ 0x174, MUXMODE(4) | INPUTENABLE },		/* gpio_144 */
   1115  1.21  kiyohara 		{ 0x176, MUXMODE(4) | INPUTENABLE },		/* gpio_145 */
   1116  1.21  kiyohara 		{ 0x178, MUXMODE(4) | INPUTENABLE },		/* gpio_146 */
   1117  1.21  kiyohara 		{ 0x17a, MUXMODE(4) | INPUTENABLE },		/* gpio_147 */
   1118  1.21  kiyohara 		{ 0x19a, MUXMODE(4) | INPUTENABLE },		/* gpio_163 */
   1119  1.21  kiyohara 		{ -1 }
   1120  1.21  kiyohara 	};
   1121  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_uart1_conf[] = {
   1122  1.21  kiyohara 		{ 0x17c, MUXMODE(0) },				/* uart1_tx */
   1123  1.21  kiyohara 		{ 0x182, MUXMODE(0) | INPUTENABLE },		/* uart1_rx */
   1124  1.21  kiyohara 		{ -1 }
   1125  1.21  kiyohara 	};
   1126  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_no_uart1_conf[] = {
   1127  1.21  kiyohara 		{ 0x17c, MUXMODE(4) | INPUTENABLE },		/* gpio_148 */
   1128  1.21  kiyohara 		{ 0x182, MUXMODE(4) | INPUTENABLE },		/* gpio_151 */
   1129  1.21  kiyohara 		{ -1 }
   1130  1.21  kiyohara 	};
   1131  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_hdq_conf[] = {
   1132  1.21  kiyohara #if 0
   1133  1.21  kiyohara 		{ 0x1c4, MUXMODE(0) | ??? | INPUTENABLE },	/* hdq_sio */
   1134  1.21  kiyohara #endif
   1135  1.21  kiyohara 		{ -1 }
   1136  1.21  kiyohara 	};
   1137  1.21  kiyohara 	static const struct omap_mux_conf overo_mux_no_hdq_conf[] = {
   1138  1.21  kiyohara 		{ 0x1c4, MUXMODE(4) | INPUTENABLE },		/* gpio_170 */
   1139  1.21  kiyohara 		{ -1 }
   1140  1.21  kiyohara 	};
   1141  1.21  kiyohara 
   1142  1.21  kiyohara 	gxio_omap_mux_config(overo_mux_40pin_header_conf);
   1143  1.21  kiyohara 	if (uart1 == force_uart1)
   1144  1.21  kiyohara 		gxio_omap_mux_config(overo_mux_uart1_conf);
   1145  1.21  kiyohara 	else
   1146  1.21  kiyohara 		gxio_omap_mux_config_address("com", 0x4806a000,
   1147  1.21  kiyohara 		    overo_mux_uart1_conf, overo_mux_no_uart1_conf);
   1148  1.21  kiyohara 	gxio_omap_mux_config_address("hdq", 0x480b2000,
   1149  1.21  kiyohara 	    overo_mux_hdq_conf, overo_mux_no_hdq_conf);
   1150  1.16  kiyohara }
   1151  1.16  kiyohara 
   1152  1.16  kiyohara static void
   1153  1.16  kiyohara chestnut_config(void)
   1154  1.16  kiyohara {
   1155  1.21  kiyohara 	static const struct omap_mux_conf chestnut_mux_conf[] = {
   1156  1.21  kiyohara 		{ 0x5ec, MUXMODE(4) },			/* gpio_22: LED (Blue)*/
   1157  1.21  kiyohara 		{ 0x5ee, MUXMODE(4) | INPUTENABLE },	/* gpio_23: Button */
   1158  1.21  kiyohara 		{ 0x5dc, MUXMODE(4) | INPUTENABLE },	/* gpio_14: Button */
   1159  1.21  kiyohara 		{ -1 }
   1160  1.21  kiyohara 	};
   1161  1.16  kiyohara 
   1162  1.16  kiyohara 	eth0_config();
   1163  1.21  kiyohara 	lcd_config('R');
   1164  1.21  kiyohara 
   1165  1.21  kiyohara 	header_40pin_config(uart1_if_exists);
   1166  1.21  kiyohara 	gxio_omap_mux_config(chestnut_mux_conf);
   1167  1.21  kiyohara }
   1168  1.21  kiyohara 
   1169  1.21  kiyohara static void
   1170  1.21  kiyohara gallop_config(void)
   1171  1.21  kiyohara {
   1172  1.21  kiyohara 	static const struct omap_mux_conf gallop43_mux_conf[] = {
   1173  1.21  kiyohara 		{ 0x5ec, MUXMODE(4) },			/* gpio_22: LED (Blue)*/
   1174  1.21  kiyohara 		{ 0x5ee, MUXMODE(4) | INPUTENABLE },	/* gpio_23: Button */
   1175  1.21  kiyohara 		{ 0x5dc, MUXMODE(4) | INPUTENABLE },	/* gpio_14: Button */
   1176  1.21  kiyohara 		{ -1 }
   1177  1.21  kiyohara 	};
   1178  1.21  kiyohara 
   1179  1.21  kiyohara 	lcd_config('R');
   1180  1.21  kiyohara 
   1181  1.21  kiyohara 	header_40pin_config(force_uart1);
   1182  1.21  kiyohara 	gxio_omap_mux_config(gallop43_mux_conf);
   1183  1.21  kiyohara }
   1184  1.21  kiyohara 
   1185  1.21  kiyohara static void
   1186  1.21  kiyohara summit_config(void)
   1187  1.21  kiyohara {
   1188  1.21  kiyohara 
   1189  1.21  kiyohara 	dvi_config();
   1190  1.21  kiyohara 
   1191  1.21  kiyohara 	header_40pin_config(uart1_if_exists);
   1192  1.16  kiyohara }
   1193  1.16  kiyohara 
   1194  1.16  kiyohara static void
   1195  1.16  kiyohara tobi_config(void)
   1196  1.16  kiyohara {
   1197  1.16  kiyohara 
   1198  1.16  kiyohara 	eth0_config();
   1199  1.21  kiyohara 	dvi_config();
   1200  1.21  kiyohara 
   1201  1.21  kiyohara 	header_40pin_config(uart1_if_exists);
   1202  1.16  kiyohara }
   1203  1.16  kiyohara 
   1204  1.16  kiyohara static void
   1205  1.16  kiyohara tobiduo_config(void)
   1206  1.16  kiyohara {
   1207  1.16  kiyohara 
   1208  1.16  kiyohara 	eth0_config();
   1209  1.16  kiyohara 	eth1_config();
   1210  1.16  kiyohara }
   1211  1.21  kiyohara 
   1212  1.21  kiyohara #elif defined(DUOVERO)
   1213  1.21  kiyohara 
   1214  1.21  kiyohara static void
   1215  1.21  kiyohara ehci_config(void)
   1216  1.21  kiyohara {
   1217  1.21  kiyohara 	uint32_t val;
   1218  1.21  kiyohara 
   1219  1.21  kiyohara #define SCRM_ALTCLKSRC		0xa110
   1220  1.21  kiyohara #define   ALTCLKSRC_ENABLE_EXT		(1 << 3)
   1221  1.21  kiyohara #define   ALTCLKSRC_ENABLE_INT		(1 << 2)
   1222  1.21  kiyohara #define   ALTCLKSRC_MODE_MASK		(3 << 0)
   1223  1.21  kiyohara #define   ALTCLKSRC_MODE_POWERDOWN	(0 << 0)
   1224  1.21  kiyohara #define   ALTCLKSRC_MODE_ACTIVE		(1 << 0)
   1225  1.21  kiyohara #define   ALTCLKSRC_MODE_BYPASS		(2 << 0)
   1226  1.21  kiyohara #define SCRM_AUXCLK3		0xa31c
   1227  1.21  kiyohara #define   AUXCLK3_CLKDIV(n)		(((n) - 1) << 16)
   1228  1.21  kiyohara #define   AUXCLK3_CLKDIV_MASK		(0xf << 16)
   1229  1.21  kiyohara #define   AUXCLK3_ENABLE		(1 << 8)
   1230  1.21  kiyohara #define   AUXCLK3_SRCSELECT_MASK	(3 << 1)
   1231  1.21  kiyohara #define   AUXCLK3_SRCSELECT_SYSCLK	(0 << 1)
   1232  1.21  kiyohara #define   AUXCLK3_SRCSELECT_CORE	(1 << 1)
   1233  1.21  kiyohara #define   AUXCLK3_SRCSELECT_PERDPLL	(2 << 1)
   1234  1.21  kiyohara #define   AUXCLK3_SRCSELECT_ALTCLK	(3 << 1)
   1235  1.21  kiyohara #define   AUXCLK3_POLARITY_LOW		(0 << 0)
   1236  1.21  kiyohara #define   AUXCLK3_POLARITY_HIGH		(1 << 0)
   1237  1.21  kiyohara 
   1238  1.21  kiyohara 	/* Use the 1/2 auxiliary clock #3 of system clock. */
   1239  1.21  kiyohara 	val = ioreg_read(DUOVERO_L4_WAKEUP_VBASE + SCRM_AUXCLK3);
   1240  1.21  kiyohara 	val &= ~(AUXCLK3_CLKDIV_MASK | AUXCLK3_SRCSELECT_MASK);
   1241  1.21  kiyohara 	val |= (AUXCLK3_CLKDIV(2) | AUXCLK3_ENABLE | AUXCLK3_SRCSELECT_SYSCLK);
   1242  1.21  kiyohara 	ioreg_write(DUOVERO_L4_WAKEUP_VBASE + SCRM_AUXCLK3, val);
   1243  1.21  kiyohara 
   1244  1.21  kiyohara 	val = ioreg_read(DUOVERO_L4_WAKEUP_VBASE + SCRM_ALTCLKSRC);
   1245  1.21  kiyohara 	val &= ~ALTCLKSRC_MODE_MASK;
   1246  1.21  kiyohara 	val |= ALTCLKSRC_MODE_ACTIVE;
   1247  1.21  kiyohara 	val |= (ALTCLKSRC_ENABLE_EXT | ALTCLKSRC_ENABLE_INT);
   1248  1.21  kiyohara 	ioreg_write(DUOVERO_L4_WAKEUP_VBASE + SCRM_ALTCLKSRC, val);
   1249  1.21  kiyohara }
   1250  1.21  kiyohara 
   1251  1.21  kiyohara static void
   1252  1.21  kiyohara parlor_config(void)
   1253  1.21  kiyohara {
   1254  1.21  kiyohara #if 0
   1255  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_40pin_header_conf[] = {
   1256  1.21  kiyohara 		/*
   1257  1.21  kiyohara 		 *  1: GND
   1258  1.21  kiyohara 		 *  2: GND
   1259  1.21  kiyohara 		 *  3: MCSPI1_CLK or GPIO 134
   1260  1.21  kiyohara 		 *  4: MCSPI1_CS0 or GPIO 137
   1261  1.21  kiyohara 		 *  5: MCSPI1_SIMO or GPIO 136
   1262  1.21  kiyohara 		 *  6: MCSPI1_CS1 or GPIO 138
   1263  1.21  kiyohara 		 *  7: MCSPI1_SOMI or GPIO 135
   1264  1.21  kiyohara 		 *  8: MCSPI1_CS2 or GPIO 139
   1265  1.21  kiyohara 		 *  9: HDQ_SIO or GPIO 127
   1266  1.21  kiyohara 		 * 10: MCSPI1_CS3 or GPIO 140
   1267  1.21  kiyohara 		 * 11: SDMMC3_CMD or GPIO ???
   1268  1.21  kiyohara 		 * 12: I2C2_SCL or GPIO 128
   1269  1.21  kiyohara 		 * 13: SDMMC3_CLK or GPIO ???
   1270  1.21  kiyohara 		 * 14: I2C2_SDA or GPIO 129
   1271  1.21  kiyohara 		 * 15: UART2_TX or SDMMC3_DAT1 or GPIO 126
   1272  1.21  kiyohara 		 * 16: PMIC_PWM2 (TWL6030)
   1273  1.21  kiyohara 		 * 17: UART2_RX or SDMMC3_DAT0 or GPIO 125
   1274  1.21  kiyohara 		 * 18: PMIC_PWM1 (TWL6030)
   1275  1.21  kiyohara 		 * 19: BSP2_CLKX or GPIO 110
   1276  1.21  kiyohara 		 * 20: BSP2_FSX or GPIO 113
   1277  1.21  kiyohara 		 * 21: BSP2_DX or GPIO 112
   1278  1.21  kiyohara 		 * 22: BSP2_DR or GPIO 111
   1279  1.21  kiyohara 		 * 23: BSP2_CLKS or GPIO 118
   1280  1.21  kiyohara 		 * 24: FREF1
   1281  1.21  kiyohara 		 * 25: MCSPI4_SOMI or GPIO 153
   1282  1.21  kiyohara 		 * 26: PMIC_NRESWARN
   1283  1.21  kiyohara 		 * 27: MCSPI4_SIMO or GPIO 152
   1284  1.21  kiyohara 		 * 28: SYSEN
   1285  1.21  kiyohara 		 * 29: MCSPI4_CLK or GPIO 151
   1286  1.21  kiyohara 		 * 30: PWRON
   1287  1.21  kiyohara 		 * 31: MCSPI4_CS0 or GPIO 154
   1288  1.21  kiyohara 		 * 32: REGEN1
   1289  1.21  kiyohara 		 * 33: ADCIN3 (TWL6030)
   1290  1.21  kiyohara 		 * 34: VCC_1.0
   1291  1.21  kiyohara 		 * 35: ADCIN4_VREF (TWL6030)
   1292  1.21  kiyohara 		 * 36: VDD_VAUX2
   1293  1.21  kiyohara 		 * 37: ADCIN4 (TWL6030)
   1294  1.21  kiyohara 		 * 38: VCC_3.3
   1295  1.21  kiyohara 		 * 39: ADCIN5 (TWL6030)
   1296  1.21  kiyohara 		 * 40: V_BATT_5
   1297  1.21  kiyohara 		 */
   1298  1.21  kiyohara 		{ -1 }
   1299  1.21  kiyohara 	};
   1300  1.21  kiyohara #endif
   1301  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_mcspi1_conf[] = {
   1302  1.21  kiyohara #if 0
   1303  1.21  kiyohara 		{ 0x132,			/*  3: MCSPI1_CLK */
   1304  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1305  1.21  kiyohara 		{ 0x138,			/*  4: MCSPI1_CS0 */
   1306  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1307  1.21  kiyohara 		{ 0x136,			/*  5: MCSPI1_SIMO */
   1308  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1309  1.21  kiyohara 		{ 0x13a,			/*  6: MCSPI1_CS1 */
   1310  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1311  1.21  kiyohara 		{ 0x134,			/*  7: MCSPI1_SOMI */
   1312  1.21  kiyohara 		  MUXMODE(0) | ??? | INPUTENABLE },
   1313  1.21  kiyohara 		{ 0x13c,			/*  8: MCSPI1_CS2 */
   1314  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1315  1.21  kiyohara 		{ 0x13e,			/* 10: MCSPI1_CS3 */
   1316  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1317  1.21  kiyohara #endif
   1318  1.21  kiyohara 		{ -1 }
   1319  1.21  kiyohara 	};
   1320  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_mcspi1_conf[] = {
   1321  1.21  kiyohara 		{ 0x132,			/*  3: GPIO 134 */
   1322  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1323  1.21  kiyohara 		{ 0x138,			/*  4: GPIO 137 */
   1324  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1325  1.21  kiyohara 		{ 0x136,			/*  5: GPIO 136 */
   1326  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1327  1.21  kiyohara 		{ 0x13a,			/*  6: GPIO 138 */
   1328  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1329  1.21  kiyohara 		{ 0x134,			/*  7: GPIO 135 */
   1330  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1331  1.21  kiyohara 		{ 0x13c,			/*  8: GPIO 139 */
   1332  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1333  1.21  kiyohara 		{ 0x13e,			/* 10: GPIO 140 */
   1334  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1335  1.21  kiyohara 		{ -1 }
   1336  1.21  kiyohara 	};
   1337  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_hdq_conf[] = {
   1338  1.21  kiyohara #if 0
   1339  1.21  kiyohara 		{ 0x120,			/*  9: HDQ_SIO */
   1340  1.21  kiyohara 		  MUXMODE(0) | ??? | INPUTENABLE },
   1341  1.21  kiyohara #endif
   1342  1.21  kiyohara 		{ -1 }
   1343  1.21  kiyohara 	};
   1344  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_hdq_conf[] = {
   1345  1.21  kiyohara 		{ 0x120,			/*  9: GPIO_127 */
   1346  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1347  1.21  kiyohara 		{ -1 }
   1348  1.21  kiyohara 	};
   1349  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_i2c2_conf[] = {
   1350  1.21  kiyohara 		{ 0x126,			/* 12: I2C2_SCL */
   1351  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1352  1.21  kiyohara 		{ 0x128,			/* 14: I2C2_SDA */
   1353  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1354  1.21  kiyohara 		{ -1 }
   1355  1.21  kiyohara 	};
   1356  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_i2c2_conf[] = {
   1357  1.21  kiyohara 		{ 0x126,			/* 12: GPIO 128 */
   1358  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1359  1.21  kiyohara 		{ 0x128,			/* 14: GPIO 129 */
   1360  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1361  1.21  kiyohara 		{ -1 }
   1362  1.21  kiyohara 	};
   1363  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_sdmmc3_conf[] = {
   1364  1.21  kiyohara #if 0
   1365  1.21  kiyohara 11	SDMMC3_CMD	  DuoVero J2 A15 <- omap pin AG10
   1366  1.21  kiyohara 		  MUXMODE(1) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1367  1.21  kiyohara 13	SDMMC3_CLK	  DuoVero J2 A16 <- omap pin AE9
   1368  1.21  kiyohara 		  MUXMODE(1) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1369  1.21  kiyohara #endif
   1370  1.21  kiyohara 		{ 0x11c,			/* 17: SDMMC3_DAT0 */
   1371  1.21  kiyohara 		  MUXMODE(1) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1372  1.21  kiyohara 		{ 0x11e,			/* 15: SDMMC3_DAT1 */
   1373  1.21  kiyohara 		  MUXMODE(1) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1374  1.21  kiyohara 		{ -1 }
   1375  1.21  kiyohara 	};
   1376  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_uart2_conf[] = {
   1377  1.21  kiyohara 		{ 0x11c,			/* 17: UART2_RX */
   1378  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1379  1.21  kiyohara 		{ 0x11e,
   1380  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE },	/* 15: UART2_TX */
   1381  1.21  kiyohara 		{ -1 }
   1382  1.21  kiyohara 	};
   1383  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_uart2_conf[] = {
   1384  1.21  kiyohara 		{ 0x11c,			/* 17: GPIO 125 */
   1385  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1386  1.21  kiyohara 		{ 0x11e,			/* 15: GPIO 126 */
   1387  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1388  1.21  kiyohara 		{ -1 }
   1389  1.21  kiyohara 	};
   1390  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_bsp2_conf[] = {
   1391  1.21  kiyohara 		{ 0x0f6,			/* 19: BSP2_CLKX */
   1392  1.21  kiyohara 		  MUXMODE(0) | INPUTENABLE },
   1393  1.21  kiyohara 		{ 0x0fc,			/* 20: BSP2_FSX */
   1394  1.21  kiyohara 		  MUXMODE(0) | INPUTENABLE },
   1395  1.21  kiyohara 		{ 0x0fa,			/* 21: BSP2_DX */
   1396  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE },
   1397  1.21  kiyohara 		{ 0x0f8,			/* 22: BSP2_DR */
   1398  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE | INPUTENABLE },
   1399  1.21  kiyohara 		{ 0x10e,			/* 23: BSP2_CLKS */
   1400  1.21  kiyohara 		  MUXMODE(0) | PULLUDENABLE | INPUTENABLE },
   1401  1.21  kiyohara 		{ -1 }
   1402  1.21  kiyohara 	};
   1403  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_bsp2_conf[] = {
   1404  1.21  kiyohara 		{ 0x0f6,			/* 19: GPIO 110 */
   1405  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1406  1.21  kiyohara 		{ 0x0fc,			/* 20: GPIO 113 */
   1407  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1408  1.21  kiyohara 		{ 0x0fa,			/* 21: GPIO 112 */
   1409  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1410  1.21  kiyohara 		{ 0x0f8,			/* 22: GPIO 111 */
   1411  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1412  1.21  kiyohara 		{ 0x10e,			/* 23: GPIO 118 */
   1413  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1414  1.21  kiyohara 		{ -1 }
   1415  1.21  kiyohara 	};
   1416  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_mcspi4_conf[] = {
   1417  1.21  kiyohara #if 0
   1418  1.21  kiyohara 		{ 0x158,			/* 25: MCSPI4_SOMI */
   1419  1.21  kiyohara 		  MUXMODE(0) | ??? | INPUTENABLE },
   1420  1.21  kiyohara 		{ 0x156,			/* 27: MCSPI4_SIMO */
   1421  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1422  1.21  kiyohara 		{ 0x154,			/* 29: MCSPI4_CLK */
   1423  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1424  1.21  kiyohara 		{ 0x15a,			/* 31: MCSPI4_CS0 */
   1425  1.21  kiyohara 		  MUXMODE(0) | ??? },
   1426  1.21  kiyohara #endif
   1427  1.21  kiyohara 		{ -1 }
   1428  1.21  kiyohara 	};
   1429  1.21  kiyohara 	static const struct omap_mux_conf parlor_mux_no_mcspi4_conf[] = {
   1430  1.21  kiyohara 		{ 0x158,			/* 25: GPIO 153 */
   1431  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1432  1.21  kiyohara 		{ 0x156,			/* 27: GPIO 152 */
   1433  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1434  1.21  kiyohara 		{ 0x154,			/* 29: GPIO 151 */
   1435  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1436  1.21  kiyohara 		{ 0x15a,			/* 31: GPIO 154 */
   1437  1.21  kiyohara 		  MUXMODE(3) | PULLUDENABLE | PULLTYPESELECT | INPUTENABLE },
   1438  1.21  kiyohara 		{ -1 }
   1439  1.21  kiyohara 	};
   1440  1.21  kiyohara 
   1441  1.21  kiyohara 	/*
   1442  1.21  kiyohara 	 * ETH0 connects via CS5.  It use GPIO 44 for IRQ.
   1443  1.21  kiyohara 	 * Also GPIO 45 is NRESET.
   1444  1.21  kiyohara 	 */
   1445  1.21  kiyohara 	smsh_config(NULL, 44, 45);
   1446  1.21  kiyohara 
   1447  1.21  kiyohara 	ehci_config();
   1448  1.21  kiyohara 
   1449  1.21  kiyohara 	gxio_omap_mux_config_address("mcspi", 0x48098000,
   1450  1.21  kiyohara 	    parlor_mux_mcspi1_conf, parlor_mux_no_mcspi1_conf);
   1451  1.21  kiyohara 	gxio_omap_mux_config_address("hdq", 0x480b2000,
   1452  1.21  kiyohara 	    parlor_mux_hdq_conf, parlor_mux_no_hdq_conf);
   1453  1.21  kiyohara 	gxio_omap_mux_config_address("tiiic", 0x48072000,
   1454  1.21  kiyohara 	    parlor_mux_i2c2_conf, parlor_mux_no_i2c2_conf);
   1455  1.21  kiyohara 	if (gxio_omap_mux_config_address("sdhc", 0x480ad000,
   1456  1.21  kiyohara 				parlor_mux_sdmmc3_conf, NULL) != 0)
   1457  1.21  kiyohara 		gxio_omap_mux_config_address("com", 0x4806c000,
   1458  1.21  kiyohara 		    parlor_mux_uart2_conf, parlor_mux_no_uart2_conf);
   1459  1.21  kiyohara 	gxio_omap_mux_config_address("mcbsp", 0x49024000,
   1460  1.21  kiyohara 	    parlor_mux_bsp2_conf, parlor_mux_no_bsp2_conf);
   1461  1.21  kiyohara 	gxio_omap_mux_config_address("mcspi", 0x480ba000,
   1462  1.21  kiyohara 	    parlor_mux_mcspi4_conf, parlor_mux_no_mcspi4_conf);
   1463  1.21  kiyohara }
   1464  1.21  kiyohara 
   1465  1.21  kiyohara #elif defined(PEPPER)
   1466  1.21  kiyohara 
   1467  1.21  kiyohara static void
   1468  1.21  kiyohara lcd_config(void)
   1469  1.21  kiyohara {
   1470  1.21  kiyohara 	static const struct tifb_panel_info panel_lcd = {
   1471  1.21  kiyohara 		.panel_tft = 1,
   1472  1.21  kiyohara 		.panel_mono = false,
   1473  1.21  kiyohara 		.panel_bpp = 24,
   1474  1.21  kiyohara 
   1475  1.21  kiyohara 		.panel_pxl_clk = 18400000,
   1476  1.21  kiyohara 		.panel_width = 480,
   1477  1.21  kiyohara 		.panel_height = 272,
   1478  1.21  kiyohara 		.panel_hfp = 8,
   1479  1.21  kiyohara 		.panel_hbp = 4,
   1480  1.21  kiyohara 		.panel_hsw = 41,
   1481  1.21  kiyohara 		.panel_vfp = 4,
   1482  1.21  kiyohara 		.panel_vbp = 2,
   1483  1.21  kiyohara 		.panel_vsw = 10,
   1484  1.21  kiyohara 		.panel_invert_hsync = 0,
   1485  1.21  kiyohara 		.panel_invert_vsync = 0,
   1486  1.21  kiyohara 
   1487  1.21  kiyohara 		.panel_ac_bias = 255,
   1488  1.21  kiyohara 		.panel_ac_bias_intrpt = 0,
   1489  1.21  kiyohara 		.panel_dma_burst_sz = 16,
   1490  1.21  kiyohara 		.panel_fdd = 0x80,
   1491  1.21  kiyohara 		.panel_sync_edge = 0,
   1492  1.21  kiyohara 		.panel_sync_ctrl = 1,
   1493  1.21  kiyohara 		.panel_tft_alt_mode = 0,
   1494  1.21  kiyohara 		.panel_invert_pxl_clk = 0,
   1495  1.21  kiyohara 	};
   1496  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_lcd_conf[] = {
   1497  1.21  kiyohara 		/*
   1498  1.21  kiyohara 		 * LCD_DATA[0-23] configures in tifb.c
   1499  1.21  kiyohara 		 */
   1500  1.21  kiyohara 
   1501  1.21  kiyohara 		{ 0x8e0, MMODE(0) | PUDEN },		/* LCD_VSYNC */
   1502  1.21  kiyohara 		{ 0x8e4, MMODE(0) | PUDEN },		/* LCD_HSYNC */
   1503  1.21  kiyohara 		{ 0x8e8, MMODE(0) | PUDEN },		/* LCD_PCLK */
   1504  1.21  kiyohara 		{ 0x8ec, MMODE(0) | PUDEN },		/* LCD_AC_BIAS_EN */
   1505  1.21  kiyohara 
   1506  1.21  kiyohara 		{ 0x86c, MMODE(7) | PUTYPESEL },	/* GPIO 59: Enable */
   1507  1.21  kiyohara 		{ -1 }
   1508  1.21  kiyohara 	};
   1509  1.21  kiyohara 
   1510  1.21  kiyohara 	if (gxio_omap_mux_config_address("tifb", 0x4830e000,
   1511  1.21  kiyohara 					pepper_mux_lcd_conf, NULL) == 0) {
   1512  1.21  kiyohara 		extern const struct tifb_panel_info *tifb_panel_info;
   1513  1.21  kiyohara 		extern bool use_tps65217_wled;
   1514  1.21  kiyohara 
   1515  1.21  kiyohara 		tifb_panel_info = &panel_lcd;
   1516  1.21  kiyohara 		use_tps65217_wled = true;
   1517  1.21  kiyohara 	}
   1518  1.21  kiyohara }
   1519  1.21  kiyohara 
   1520  1.21  kiyohara static void
   1521  1.21  kiyohara pepper43_config(void)
   1522  1.21  kiyohara {
   1523  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_wilink8_conf[] = {
   1524  1.21  kiyohara 		/* TI WiLink 8 */
   1525  1.21  kiyohara 		{ 0x800, MMODE(7) | PUTYPESEL },	/* GPIO 32: Bluetooth */
   1526  1.21  kiyohara 		{ 0x804, MMODE(7) | PUDEN | RXACTIVE },	/* GPIO 33: irq   */
   1527  1.21  kiyohara 		{ 0x860, MMODE(7) | PUTYPESEL },	/* GPIO 56: WiFi  */
   1528  1.21  kiyohara 		{ -1 }
   1529  1.21  kiyohara 	};
   1530  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_i2c1_conf[] = {
   1531  1.21  kiyohara 		{ 0x968, MMODE(3) | PUTYPESEL | RXACTIVE },	/* I2C1_SDA */
   1532  1.21  kiyohara 		{ 0x96c, MMODE(3) | PUTYPESEL | RXACTIVE },	/* I2C1_SCL */
   1533  1.21  kiyohara 		{ -1 }
   1534  1.21  kiyohara 	};
   1535  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mpu9150_conf[] = {
   1536  1.21  kiyohara 		/* MPU9150 at I2C1 */
   1537  1.21  kiyohara 		{ 0x808, MMODE(7) | PUDEN | RXACTIVE },	/* GPIO 34: IRQ */
   1538  1.21  kiyohara 		{ 0x898, MMODE(7) | PUDEN | RXACTIVE },	/* GPIO 68 */
   1539  1.21  kiyohara 		{ 0x870, MMODE(7) | PUDEN | RXACTIVE },	/* GPIO 30 */
   1540  1.21  kiyohara 		{ -1 }
   1541  1.21  kiyohara 	};
   1542  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_20pin_header_conf[] = {
   1543  1.21  kiyohara 		{ 0x85c, MMODE(7) | PUDEN | RXACTIVE },	/*  1: GPIO 55 */
   1544  1.21  kiyohara 		{ 0x80c, MMODE(7) | PUDEN | RXACTIVE },	/*  2: GPIO 35 */
   1545  1.21  kiyohara 		{ 0x810, MMODE(7) | PUDEN | RXACTIVE },	/*  3: GPIO 36 */
   1546  1.21  kiyohara 		{ 0x814, MMODE(7) | PUDEN | RXACTIVE },	/*  4: GPIO 37 */
   1547  1.21  kiyohara 		{ 0x818, MMODE(7) | PUDEN | RXACTIVE },	/*  5: GPIO 38 */
   1548  1.21  kiyohara 		{ 0x81c, MMODE(7) | PUDEN | RXACTIVE },	/*  6: GPIO 39 */
   1549  1.21  kiyohara 		{ 0x87c, MMODE(7) | PUDEN | RXACTIVE },	/*  7: GPIO 61 */
   1550  1.21  kiyohara 		{ 0x880, MMODE(7) | PUDEN | RXACTIVE },	/*  8: GPIO 62 */
   1551  1.21  kiyohara 		{ 0x884, MMODE(7) | PUDEN | RXACTIVE },	/*  9: GPIO 63 */
   1552  1.21  kiyohara 		{ 0x9e4, MMODE(7) | PUDEN | RXACTIVE },	/* 10: GPIO 103 */
   1553  1.21  kiyohara 		{ 0x9e8, MMODE(7) | PUDEN | RXACTIVE },	/* 11: GPIO 104 */
   1554  1.21  kiyohara 		{ 0x9b0, MMODE(7) | PUDEN | RXACTIVE },	/* 12: GPIO 19 */
   1555  1.21  kiyohara #if 0	/* UART3 or GPIO */
   1556  1.21  kiyohara 		{ 0x964, MMODE(7) | PUDEN | RXACTIVE },	/* 13: GPIO 7 */
   1557  1.21  kiyohara 		{ 0x960, MMODE(7) | PUDEN | RXACTIVE },	/* 14: GPIO 6 */
   1558  1.21  kiyohara #endif
   1559  1.21  kiyohara #if 0	/* UART2 or GPIO */
   1560  1.21  kiyohara 		{ 0x910, MMODE(7) | PUDEN | RXACTIVE },	/* 15: GPIO 98 */
   1561  1.21  kiyohara 		{ 0x90c, MMODE(7) | PUDEN | RXACTIVE },	/* 16: GPIO 97 */
   1562  1.21  kiyohara #endif
   1563  1.21  kiyohara 							/* 17: VCC 5v */
   1564  1.21  kiyohara 							/* 18: VCC 3.3v */
   1565  1.21  kiyohara 							/* 19: GND */
   1566  1.21  kiyohara 							/* 20: GND */
   1567  1.21  kiyohara 		{ -1 }
   1568  1.21  kiyohara 	};
   1569  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_uart2_conf[] = {
   1570  1.21  kiyohara 		{ 0x90c, MMODE(6) | PUTYPESEL | RXACTIVE },	/* UART2_RXD */
   1571  1.21  kiyohara 		{ 0x910, MMODE(6) | PUDEN },			/* UART2_TXD */
   1572  1.21  kiyohara 		{ -1 }
   1573  1.21  kiyohara 	};
   1574  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_no_uart2_conf[] = {
   1575  1.21  kiyohara 		{ 0x90c, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 97 */
   1576  1.21  kiyohara 		{ 0x910, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 98 */
   1577  1.21  kiyohara 		{ -1 }
   1578  1.21  kiyohara 	};
   1579  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_uart3_conf[] = {
   1580  1.21  kiyohara 		{ 0x960, MMODE(1) | PUTYPESEL | RXACTIVE },	/* UART3_RXD */
   1581  1.21  kiyohara 		{ 0x964, MMODE(1) | PUDEN },			/* UART3_TXD */
   1582  1.21  kiyohara 		{ -1 }
   1583  1.21  kiyohara 	};
   1584  1.21  kiyohara 	static const struct omap_mux_conf pepper43_mux_no_uart3_conf[] = {
   1585  1.21  kiyohara 		{ 0x960, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 6 */
   1586  1.21  kiyohara 		{ 0x964, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 7 */
   1587  1.21  kiyohara 		{ -1 }
   1588  1.21  kiyohara 	};
   1589  1.21  kiyohara 
   1590  1.21  kiyohara 	static const struct omap_mux_conf *pepper43_mux_conf[] = {
   1591  1.21  kiyohara 		pepper43_mux_wilink8_conf,
   1592  1.21  kiyohara 		pepper43_mux_i2c1_conf,
   1593  1.21  kiyohara 		pepper43_mpu9150_conf,
   1594  1.21  kiyohara 		pepper43_mux_20pin_header_conf,
   1595  1.21  kiyohara 	};
   1596  1.21  kiyohara 
   1597  1.21  kiyohara 	static const struct omap_gpio_conf pepper43_gpio_wl18xx_conf[] = {
   1598  1.21  kiyohara 		{  32, conf_output_0 },		/* #Reset: Bluetooth */
   1599  1.21  kiyohara 		{  56, conf_output_0 },		/* #Reset: WiFi */
   1600  1.21  kiyohara 		{ -1 }
   1601  1.21  kiyohara 	};
   1602  1.21  kiyohara 	int i;
   1603  1.21  kiyohara 
   1604  1.21  kiyohara 	lcd_config();
   1605  1.21  kiyohara 
   1606  1.21  kiyohara 	for (i = 0; i < __arraycount(pepper43_mux_conf); i++)
   1607  1.21  kiyohara 		gxio_omap_mux_config(pepper43_mux_conf[i]);
   1608  1.21  kiyohara 	gxio_omap_gpio_config(pepper43_gpio_wl18xx_conf);
   1609  1.21  kiyohara 
   1610  1.21  kiyohara #if 0
   1611  1.21  kiyohara 	ioreg_write(gpio1_base + GPIO_SIZE2 + GPIO_OE,	/* GPIO 52 (Blue) */
   1612  1.21  kiyohara 	    ioreg_read(gpio1_base + GPIO_SIZE2 + GPIO_OE) & ~(1 << 20));
   1613  1.21  kiyohara 	ioreg_write(gpio1_base + GPIO_SIZE2 + GPIO_DATAOUT,
   1614  1.21  kiyohara 	    ioreg_read(gpio1_base + GPIO_SIZE2 + GPIO_DATAOUT) | (1 << 20));
   1615  1.21  kiyohara 	ioreg_write(gpio1_base + GPIO_SIZE2 + GPIO_OE,	/* GPIO 53 (Red) */
   1616  1.21  kiyohara 	    ioreg_read(gpio1_base + GPIO_SIZE2 + GPIO_OE) & ~(1 << 21));
   1617  1.21  kiyohara 	ioreg_write(gpio1_base + GPIO_SIZE2 + GPIO_DATAOUT,
   1618  1.21  kiyohara 	    ioreg_read(gpio1_base + GPIO_SIZE2 + GPIO_DATAOUT) | (1 << 21));
   1619  1.21  kiyohara #endif
   1620  1.21  kiyohara 
   1621  1.21  kiyohara 	gxio_omap_mux_config_address("com", 0x48024000,
   1622  1.21  kiyohara 	    pepper43_mux_uart2_conf, pepper43_mux_no_uart2_conf);
   1623  1.21  kiyohara 	gxio_omap_mux_config_address("com", 0x481a6000,
   1624  1.21  kiyohara 	    pepper43_mux_uart3_conf, pepper43_mux_no_uart3_conf);
   1625  1.21  kiyohara }
   1626  1.21  kiyohara 
   1627  1.21  kiyohara static void
   1628  1.21  kiyohara pepper_config(void)
   1629  1.21  kiyohara {
   1630  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_button2_conf[] = {
   1631  1.21  kiyohara 		{ 0x85c, MMODE(7) | PUTYPESEL | RXACTIVE },	/* GPIO 55 */
   1632  1.21  kiyohara 		{ -1 }
   1633  1.21  kiyohara 	};
   1634  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_i2c1_conf[] = {
   1635  1.21  kiyohara 		{ 0x90c, MMODE(3) | PUTYPESEL | RXACTIVE },	/* I2C1_SDA */
   1636  1.21  kiyohara 		{ 0x910, MMODE(3) | PUTYPESEL | RXACTIVE },	/* I2C1_SCL */
   1637  1.21  kiyohara 		{ -1 }
   1638  1.21  kiyohara 	};
   1639  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_wi2wi_conf[] = {
   1640  1.21  kiyohara 		{ 0x9b4, MMODE(3) | PUDEN },			/* CLKOUT2 */
   1641  1.21  kiyohara 		/* Wi2Wi */
   1642  1.21  kiyohara 		{ 0x860, MMODE(7) | PUTYPESEL },	/* GPIO 56: nReset */
   1643  1.21  kiyohara 		{ 0x870, MMODE(7) | PUTYPESEL },	/* GPIO 30: nPower */
   1644  1.21  kiyohara 		{ -1 }
   1645  1.21  kiyohara 	};
   1646  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_uart1_conf[] = {
   1647  1.21  kiyohara 		{ 0x978, MMODE(0) | PUTYPESEL | RXACTIVE },	/* UART1_CTSn */
   1648  1.21  kiyohara 		{ 0x97c, MMODE(0) },				/* UART1_RTSn */
   1649  1.21  kiyohara 		{ 0x980, MMODE(0) | PUTYPESEL | RXACTIVE },	/* UART1_RXD */
   1650  1.21  kiyohara 		{ 0x984, MMODE(0) },				/* UART1_TXD */
   1651  1.21  kiyohara 		{ -1 }
   1652  1.21  kiyohara 	};
   1653  1.21  kiyohara 	static const struct omap_mux_conf pepper_mux_no_uart1_conf[] = {
   1654  1.21  kiyohara 		{ 0x978, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 12 */
   1655  1.21  kiyohara 		{ 0x97c, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 13 */
   1656  1.21  kiyohara 		{ 0x980, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 14 */
   1657  1.21  kiyohara 		{ 0x984, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 15 */
   1658  1.21  kiyohara 		{ -1 }
   1659  1.21  kiyohara 	};
   1660  1.21  kiyohara 	static const struct omap_mux_conf *pepper_mux_conf[] = {
   1661  1.21  kiyohara 		pepper_mux_button2_conf,
   1662  1.21  kiyohara 		pepper_mux_i2c1_conf,
   1663  1.21  kiyohara 		pepper_mux_wi2wi_conf,
   1664  1.21  kiyohara 	};
   1665  1.21  kiyohara 
   1666  1.21  kiyohara 	int i;
   1667  1.21  kiyohara 
   1668  1.21  kiyohara 	lcd_config();
   1669  1.21  kiyohara 
   1670  1.21  kiyohara 	for (i = 0; i < __arraycount(pepper_mux_conf); i++)
   1671  1.21  kiyohara 		gxio_omap_mux_config(pepper_mux_conf[i]);
   1672  1.21  kiyohara 	gxio_omap_mux_config_address("com", 0x48022000,
   1673  1.21  kiyohara 	    pepper_mux_uart1_conf, pepper_mux_no_uart1_conf);
   1674  1.21  kiyohara }
   1675  1.21  kiyohara 
   1676  1.21  kiyohara static void
   1677  1.21  kiyohara c_config(void)
   1678  1.21  kiyohara {
   1679  1.21  kiyohara 	static const struct omap_mux_conf pepper43c_mux_ft5306_conf[] = {
   1680  1.21  kiyohara 		/* FT5306 at I2C2 */
   1681  1.21  kiyohara 		{ 0x9b4, MMODE(7) | PUDEN | RXACTIVE },		/* GPIO 20 */
   1682  1.21  kiyohara 		{ 0x95c, MMODE(7) | PUDEN },			/* GPIO 5 */
   1683  1.21  kiyohara 		{ -1 }
   1684  1.21  kiyohara 	};
   1685  1.21  kiyohara 	static const struct omap_mux_conf pepper43c_mux_i2c2_conf[] = {
   1686  1.21  kiyohara 		{ 0x950, MMODE(2) | PUTYPESEL | RXACTIVE },	/* I2C2_SDA */
   1687  1.21  kiyohara 		{ 0x954, MMODE(2) | PUTYPESEL | RXACTIVE },	/* I2C2_SCL */
   1688  1.21  kiyohara 		{ -1 }
   1689  1.21  kiyohara 	};
   1690  1.21  kiyohara 	static const struct omap_mux_conf *pepper43c_mux_conf[] = {
   1691  1.21  kiyohara 		pepper43c_mux_ft5306_conf,
   1692  1.21  kiyohara 		pepper43c_mux_i2c2_conf,
   1693  1.21  kiyohara 	};
   1694  1.21  kiyohara 
   1695  1.21  kiyohara 	static const struct omap_gpio_conf pepper43c_gpio_ft5306_conf[] = {
   1696  1.21  kiyohara 		{   5, conf_output_0 },		/* #Reset */
   1697  1.21  kiyohara 		{ -1 }
   1698  1.21  kiyohara 	};
   1699  1.21  kiyohara 	int i;
   1700  1.21  kiyohara 
   1701  1.21  kiyohara 	pepper43_config();
   1702  1.21  kiyohara 
   1703  1.21  kiyohara 	for (i = 0; i < __arraycount(pepper43c_mux_conf); i++)
   1704  1.21  kiyohara 		gxio_omap_mux_config(pepper43c_mux_conf[i]);
   1705  1.21  kiyohara 	gxio_omap_gpio_config(pepper43c_gpio_ft5306_conf);
   1706  1.21  kiyohara }
   1707  1.21  kiyohara 
   1708  1.21  kiyohara static void
   1709  1.21  kiyohara dvi_config(void)
   1710  1.21  kiyohara {
   1711  1.21  kiyohara 	/* XXXX: hmm... mismatch found in Linux's dts and pubs.gumstix.org... */
   1712  1.21  kiyohara 
   1713  1.21  kiyohara 	extern struct cfdata cfdata[];
   1714  1.21  kiyohara 	extern const struct tifb_panel_info *tifb_panel_info;
   1715  1.21  kiyohara 
   1716  1.21  kiyohara 	static const struct tifb_panel_info panel_dvi = {
   1717  1.21  kiyohara 		.panel_tft = 1,
   1718  1.21  kiyohara 		.panel_mono = false,
   1719  1.21  kiyohara 		.panel_bpp = 16,
   1720  1.21  kiyohara 
   1721  1.21  kiyohara 		.panel_pxl_clk = 63500000,
   1722  1.21  kiyohara 		.panel_width = 1024,
   1723  1.21  kiyohara 		.panel_height = 768,
   1724  1.21  kiyohara 		.panel_hfp = 8,
   1725  1.21  kiyohara 		.panel_hbp = 4,
   1726  1.21  kiyohara 		.panel_hsw = 41,
   1727  1.21  kiyohara 		.panel_vfp = 4,
   1728  1.21  kiyohara 		.panel_vbp = 2,
   1729  1.21  kiyohara 		.panel_vsw = 10,
   1730  1.21  kiyohara 		.panel_invert_hsync = 0,
   1731  1.21  kiyohara 		.panel_invert_vsync = 0,
   1732  1.21  kiyohara 
   1733  1.21  kiyohara 		.panel_ac_bias = 255,
   1734  1.21  kiyohara 		.panel_ac_bias_intrpt = 0,
   1735  1.21  kiyohara 		.panel_dma_burst_sz = 16,
   1736  1.21  kiyohara 		.panel_fdd = 0x80,
   1737  1.21  kiyohara 		.panel_sync_edge = 0,
   1738  1.21  kiyohara 		.panel_sync_ctrl = 1,
   1739  1.21  kiyohara 		.panel_invert_pxl_clk = 0,
   1740  1.21  kiyohara 	};
   1741  1.21  kiyohara 	cfdata_t cf = &cfdata[0];
   1742  1.21  kiyohara 
   1743  1.21  kiyohara 	/* Disable wireless module. */
   1744  1.21  kiyohara 	while (cf->cf_name != NULL) {
   1745  1.21  kiyohara 		if (strcmp(cf->cf_name, "sdhc") == 0 &&
   1746  1.21  kiyohara 		    strcmp(cf->cf_atname, "mainbus") == 0 &&
   1747  1.21  kiyohara 		    cf->cf_loc[MAINBUSCF_BASE] == 0x47810000) {
   1748  1.21  kiyohara 			if (cf->cf_fstate == FSTATE_NOTFOUND)
   1749  1.21  kiyohara 				cf->cf_fstate = FSTATE_DNOTFOUND;
   1750  1.21  kiyohara 			else if (cf->cf_fstate == FSTATE_STAR)
   1751  1.21  kiyohara 				cf->cf_fstate = FSTATE_DSTAR;
   1752  1.21  kiyohara 		}
   1753  1.21  kiyohara 		cf++;
   1754  1.21  kiyohara 	}
   1755  1.21  kiyohara 
   1756  1.21  kiyohara 	tifb_panel_info = &panel_dvi;
   1757  1.21  kiyohara }
   1758  1.21  kiyohara 
   1759  1.21  kiyohara static void
   1760  1.21  kiyohara r_config(void)
   1761  1.21  kiyohara {
   1762  1.21  kiyohara 	static const struct omap_mux_conf pepper43r_mux_ads7846_conf[] = {
   1763  1.21  kiyohara 		/* ADS7846 at McSPI0 */
   1764  1.21  kiyohara 		{ 0x9b4, MMODE(7) | PUDEN | RXACTIVE },	/* GPIO 20: IRQ */
   1765  1.21  kiyohara 		{ -1 }
   1766  1.21  kiyohara 	};
   1767  1.21  kiyohara 	static const struct omap_mux_conf pepper43r_mux_spi0_conf[] = {
   1768  1.21  kiyohara 		{ 0x950, MMODE(0) | PUTYPESEL | RXACTIVE },	/* SPI0_SCLK */
   1769  1.21  kiyohara 		{ 0x954, MMODE(0) | PUTYPESEL | RXACTIVE },	/* SPI0_D0 */
   1770  1.21  kiyohara 		{ 0x958, MMODE(0) | PUTYPESEL | RXACTIVE },	/* SPI0_D1 */
   1771  1.21  kiyohara 		{ 0x95c, MMODE(0) | PUTYPESEL | RXACTIVE },	/* SPI0_CS0 */
   1772  1.21  kiyohara 		{ -1 }
   1773  1.21  kiyohara 	};
   1774  1.21  kiyohara 	static const struct omap_mux_conf *pepper43r_mux_conf[] = {
   1775  1.21  kiyohara 		pepper43r_mux_ads7846_conf,
   1776  1.21  kiyohara 		pepper43r_mux_spi0_conf,
   1777  1.21  kiyohara 	};
   1778  1.21  kiyohara 	int i;
   1779  1.21  kiyohara 
   1780  1.21  kiyohara 	pepper43_config();
   1781  1.21  kiyohara 
   1782  1.21  kiyohara 	for (i = 0; i < __arraycount(pepper43r_mux_conf); i++)
   1783  1.21  kiyohara 		gxio_omap_mux_config(pepper43r_mux_conf[i]);
   1784  1.21  kiyohara }
   1785  1.21  kiyohara 
   1786  1.21  kiyohara #endif
   1787  1.21  kiyohara 
   1788  1.21  kiyohara #if defined(OVERO) || defined(DUOVERO)
   1789  1.21  kiyohara static void
   1790  1.21  kiyohara smsh_config(struct omap_mux_conf *smsh_mux_conf, int intr, int nreset)
   1791  1.21  kiyohara {
   1792  1.21  kiyohara 	struct omap_gpio_conf smsh_gpio_conf[] = {
   1793  1.21  kiyohara 		{ intr,		conf_input },
   1794  1.21  kiyohara 		{ nreset,	conf_output_0 },
   1795  1.21  kiyohara 		{ -1 }
   1796  1.21  kiyohara 	};
   1797  1.21  kiyohara 
   1798  1.21  kiyohara 	/*
   1799  1.21  kiyohara 	 * Basically use current settings by U-Boot.
   1800  1.21  kiyohara 	 * However remap physical address to configured address.
   1801  1.21  kiyohara 	 */
   1802  1.21  kiyohara 
   1803  1.21  kiyohara 	if (smsh_mux_conf != NULL)
   1804  1.21  kiyohara 		gxio_omap_mux_config(smsh_mux_conf);
   1805  1.21  kiyohara 	gxio_omap_gpio_config(smsh_gpio_conf);
   1806  1.21  kiyohara 	__udelay(100000);
   1807  1.21  kiyohara 	gxio_omap_gpio_write(nreset, 1);
   1808  1.21  kiyohara }
   1809  1.21  kiyohara #endif
   1810  1.21  kiyohara 
   1811  1.21  kiyohara #if defined(OVERO) || defined(DUOVERO) || defined(PEPPER)
   1812  1.21  kiyohara /*
   1813  1.21  kiyohara  * The delay for configuration time.
   1814  1.21  kiyohara  * This function use initialized timer by U-Boot.
   1815  1.21  kiyohara  */
   1816  1.21  kiyohara static void
   1817  1.21  kiyohara __udelay(unsigned int usec)
   1818  1.21  kiyohara {
   1819  1.21  kiyohara #if defined(OVERO) || defined(DUOVERO)
   1820  1.21  kiyohara #define V_SCLK			(26000000 >> 1)
   1821  1.21  kiyohara #define TCRR			0x28
   1822  1.21  kiyohara #elif defined(PEPPER)
   1823  1.21  kiyohara #define V_SCLK			24000000
   1824  1.21  kiyohara #define TCRR			0x3c
   1825  1.21  kiyohara #endif
   1826  1.21  kiyohara #define SYS_PTV			2
   1827  1.21  kiyohara #define TIMER_CLOCK		(V_SCLK / (2 << SYS_PTV))
   1828  1.21  kiyohara 
   1829  1.21  kiyohara 	const vaddr_t timer_base =
   1830  1.21  kiyohara #if defined(OVERO)
   1831  1.21  kiyohara 	    OVERO_L4_PERIPHERAL_VBASE + 0x32000;
   1832  1.21  kiyohara #elif defined(DUOVERO)
   1833  1.21  kiyohara 	    DUOVERO_L4_PERIPHERAL_VBASE + 0x32000;
   1834  1.21  kiyohara #elif defined(PEPPER)
   1835  1.21  kiyohara 	    PEPPER_L4_PERIPHERAL_VBASE + 0x40000;
   1836  1.21  kiyohara #endif
   1837  1.21  kiyohara 	long timo = usec * (TIMER_CLOCK / 1000) / 1000;
   1838  1.21  kiyohara 	uint32_t now, last;
   1839  1.21  kiyohara 
   1840  1.21  kiyohara 	last = ioreg_read(timer_base + TCRR);
   1841  1.21  kiyohara 	while (timo > 0) {
   1842  1.21  kiyohara 		now = ioreg_read(timer_base + TCRR);
   1843  1.21  kiyohara 		if (last > now)
   1844  1.21  kiyohara 			timo -= __BITS(0, 31) - last + now + 1;
   1845  1.21  kiyohara 		else
   1846  1.21  kiyohara 			timo -= now - last;
   1847  1.21  kiyohara 		last = now;
   1848  1.21  kiyohara 	}
   1849  1.21  kiyohara }
   1850  1.21  kiyohara #endif
   1851  1.21  kiyohara 
   1852  1.21  kiyohara #if defined(PEPPER)
   1853  1.21  kiyohara static int
   1854  1.21  kiyohara read_i2c_device(const vaddr_t i2c_base, uint16_t sa, uint8_t addr, int len,
   1855  1.21  kiyohara 		uint8_t *buf)
   1856  1.21  kiyohara {
   1857  1.21  kiyohara 	uint16_t v;
   1858  1.21  kiyohara 	int aok = 0, cnt = 0;
   1859  1.21  kiyohara 
   1860  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS, 0xffff);
   1861  1.21  kiyohara 	v = ioreg16_read(i2c_base + OMAP2_I2C_IRQSTATUS_RAW);
   1862  1.21  kiyohara 	while (v & I2C_IRQSTATUS_BB) {
   1863  1.21  kiyohara 		ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS, v);
   1864  1.21  kiyohara 		__udelay(20);
   1865  1.21  kiyohara 		v = ioreg16_read(i2c_base + OMAP2_I2C_IRQSTATUS_RAW);
   1866  1.21  kiyohara 	}
   1867  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS, 0xffff);
   1868  1.21  kiyohara 
   1869  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_SA, sa);
   1870  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_CNT, sizeof(addr));
   1871  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_CON,
   1872  1.21  kiyohara 	    I2C_CON_EN | I2C_CON_MST | I2C_CON_TRX | I2C_CON_STP | I2C_CON_STT);
   1873  1.21  kiyohara 	while (1 /*CONSTCOND*/) {
   1874  1.21  kiyohara 		__udelay(20);
   1875  1.21  kiyohara 		v = ioreg16_read(i2c_base + OMAP2_I2C_IRQSTATUS_RAW);
   1876  1.21  kiyohara 		if ((v & I2C_IRQSTATUS_XRDY) && aok == 0) {
   1877  1.21  kiyohara 			aok = 1;
   1878  1.21  kiyohara 			ioreg16_write(i2c_base + OMAP2_I2C_DATA, addr);
   1879  1.21  kiyohara 			ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS,
   1880  1.21  kiyohara 			    I2C_IRQSTATUS_XRDY);
   1881  1.21  kiyohara 		}
   1882  1.21  kiyohara 		if (v & I2C_IRQSTATUS_ARDY) {
   1883  1.21  kiyohara 			ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS,
   1884  1.21  kiyohara 			    I2C_IRQSTATUS_ARDY);
   1885  1.21  kiyohara 			break;
   1886  1.21  kiyohara 		}
   1887  1.21  kiyohara 	}
   1888  1.21  kiyohara 
   1889  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_SA, sa);
   1890  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_CNT, len);
   1891  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_CON,
   1892  1.21  kiyohara 	    I2C_CON_EN | I2C_CON_MST | I2C_CON_STP | I2C_CON_STT);
   1893  1.21  kiyohara 	while (1 /*CONSTCOND*/) {
   1894  1.21  kiyohara 		v = ioreg16_read(i2c_base + OMAP2_I2C_IRQSTATUS_RAW);
   1895  1.21  kiyohara 		if (v & I2C_IRQSTATUS_RRDY &&
   1896  1.21  kiyohara 		    cnt < len) {
   1897  1.21  kiyohara 			buf[cnt++] = ioreg16_read(i2c_base + OMAP2_I2C_DATA);
   1898  1.21  kiyohara 			ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS,
   1899  1.21  kiyohara 			    I2C_IRQSTATUS_RRDY);
   1900  1.21  kiyohara 		}
   1901  1.21  kiyohara 		if (v & I2C_IRQSTATUS_ARDY) {
   1902  1.21  kiyohara 			ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS,
   1903  1.21  kiyohara 			    I2C_IRQSTATUS_ARDY);
   1904  1.21  kiyohara 			break;
   1905  1.21  kiyohara 		}
   1906  1.21  kiyohara 	}
   1907  1.21  kiyohara 	ioreg16_write(i2c_base + OMAP2_I2C_IRQSTATUS, 0xffff);
   1908  1.21  kiyohara 	return 0;
   1909  1.21  kiyohara }
   1910  1.15  kiyohara #endif
   1911