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