This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC not working in our custom board

Hi Experts,

We are using am335x evm in our custom board and we are using am335x-5.05.00 source code in our board.we downloaded the am335x-5.06.00 source ti_adc driver in our kernel.we made the neccessary changes in our kernel and board file using the guide http://processors.wiki.ti.com/index.php/AM335x_ADC_Driver%27s_Guide.the folder /sys/bus/iio/devices/iio not created in our kernel,so we are not able to read the adc voltage level.can you please suggest me solve this issue.

Board file changes in our custom board.

static struct adc_data am335x_adc_data = {
.adc_channels = 8,
};

static struct mfd_tscadc_board tscadc = {
/* .tsc_init = &am335x_touchscreen_data, */
.adc_init = &am335x_adc_data,
};

static struct pinmux_config adc_pin_mux[] = {
{"ain0.ain0", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"ain2.ain2", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"vrefp.vrefp", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{"vrefn.vrefn", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
{NULL, 0},
};

  • Hi Senthil,

    As you probably know raw ADC is not supported in PSP version 04.06.00.08, which is included in the SDK 05.05.00.00 you are using. Just downloading the TI ADC driver from the latest SDK probably won't work. You need to check the official AM335x Arago Linux git repository for the patches you need (Raw ADC support is included between PSP version 04.06.00.08 and PSP version 04.06.00.09). However, I recommend simply downloading and using the latest stable PSP release from the SDK downloads page. The PSP version in the latest SDK 05.06.00.00 is PSP 04.06.00.09.

    I also want to note that the contents of AM335x ADC Driver's Guide are currently ahead of time and some of the features described in the wiki page are not present in the current official stable PSP release (version 04.06.00.09). Check out this post for more information if you want to test these features.

    Best regards,
    Miroslav

  • Hi Experts,

     We downloaded the linux-3.2.0-psp05.06.00.00 kernel. we added the custom board neccesary changes in this kernel.we followed the link:http://processors.wiki.ti.com/index.php/AMSDK_Linux_User%27s_Guide.We added the ADC driver board file code:

    #include <linux/platform_data/ti_adc.h>

    /* TSc controller */
    static struct adc_data am335x_adc_data = {
    .adc_channels = 8,
    };

    static struct mfd_tscadc_board tscadc = {
    .adc_init = &am335x_adc_data,
    };

    static struct pinmux_config adc_pin_mux[] = {
    {"ain0.ain0", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
    {"ain2.ain2", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
    {"vrefp.vrefp", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
    {"vrefn.vrefn", OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
    {NULL, 0},
    };

    static void mfd_tscadc_init(void)
    {
    int err;
    setup_pin_mux(adc_pin_mux);

    err = am33xx_register_mfd_tscadc(&tscadc);
    if (err)
    pr_err("failed to register touchscreen device\n");
    }

    {mfd_tscadc_init},

    But we got the kernel panic message like this.

    [ 1.456451] Internal error: Oops: 5 [#1]
    [ 1.460540] Modules linked in:
    [ 1.463714] CPU: 0 Not tainted (3.2.0 #6)
    [ 1.468292] PC is at ti_tscadc_probe+0x50/0x344
    [ 1.473022] LR is at console_unlock+0x170/0x1f8
    [ 1.477722] pc : [<c0430d58>] lr : [<c003e2f4>] psr: a0000013
    [ 1.477752] sp : c781de40 ip : c781dd38 fp : c781de74
    [ 1.489715] r10: c05dfedc r9 : 00000000 r8 : 00000000
    [ 1.495147] r7 : c0640438 r6 : c0660370 r5 : c786ac00 r4 : c7868740
    [ 1.501953] r3 : c061e7c8 r2 : 00000000 r1 : 00000000 r0 : 00000056
    [ 1.508758] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
    [ 1.516357] Control: 10c5387d Table: 80004019 DAC: 00000015
    [ 1.522369] Process swapper (pid: 1, stack limit = 0xc781c2f0)
    [ 1.528442] Stack: (0xc781de40 to 0xc781e000)
    [ 1.532989] de40: 00000000 c05dfedc c781de64 c786ac08 c06883c0 c0660370 c0640438 00000000
    [ 1.541503] de60: 00000000 c05dfedc c781de84 c781de78 c022db60 c0430d14 c781deb4 c781de88
    [ 1.550048] de80: c022c578 c022db4c c781deb4 c781de98 c022df38 c786ac08 c0640438 c786ac3c
    [ 1.558563] dea0: 00000000 00000000 c781ded4 c781deb8 c022c828 c022c4c4 c022c794 c0640438
    [ 1.567077] dec0: c022c794 00000000 c781defc c781ded8 c022b4dc c022c7a0 c7806ef8 c7867c70
    [ 1.575622] dee0: c01cdaf4 c0640438 c063f660 c73ceac0 c781df0c c781df00 c022c170 c022b490
    [ 1.584136] df00: c781df3c c781df10 c022bddc c022c158 c051ff54 c781df20 c0640438 c05fd08c
    [ 1.592681] df20: c781c000 00000000 00000000 c05dfedc c781df64 c781df40 c022cdcc c022bc4c
    [ 1.601196] df40: 00000000 c0666100 c05fd08c c781c000 00000000 00000000 c781df74 c781df68
    [ 1.609710] df60: c022e030 c022cd58 c781df84 c781df78 c05dfef4 c022dfe0 c781dfdc c781df88
    [ 1.618255] df80: c000876c c05dfee8 c00757e0 c00f7394 0000007f c00f7210 c781dfbc 3231df38
    [ 1.626770] dfa0: 00000037 00000000 c781dfc4 0000018c c062c9a0 c05fce58 c05fd08c c0040cc8
    [ 1.635314] dfc0: 00000013 00000000 00000000 00000000 c781dff4 c781dfe0 c05bf884 c000873c
    [ 1.643829] dfe0: 00000000 c05bf7e8 00000000 c781dff8 c0040cc8 c05bf7f4 fbf31e3e bff6c9f7
    [ 1.652343] Backtrace:
    [ 1.654937] [<c0430d08>] (ti_tscadc_probe+0x0/0x344) from [<c022db60>] (platform_drv_probe+0x20/0x24)
    [ 1.664550] [<c022db40>] (platform_drv_probe+0x0/0x24) from [<c022c578>] (driver_probe_device+0xc0/0x2dc)
    [ 1.674530] [<c022c4b8>] (driver_probe_device+0x0/0x2dc) from [<c022c828>] (__driver_attach+0x94/0x98)
    [ 1.684234] r8:00000000 r7:00000000 r6:c786ac3c r5:c0640438 r4:c786ac08
    [ 1.691223] [<c022c794>] (__driver_attach+0x0/0x98) from [<c022b4dc>] (bus_for_each_dev+0x58/0x84)
    [ 1.700561] r6:00000000 r5:c022c794 r4:c0640438 r3:c022c794
    [ 1.706481] [<c022b484>] (bus_for_each_dev+0x0/0x84) from [<c022c170>] (driver_attach+0x24/0x28)
    [ 1.715637] r6:c73ceac0 r5:c063f660 r4:c0640438
    [ 1.720458] [<c022c14c>] (driver_attach+0x0/0x28) from [<c022bddc>] (bus_add_driver+0x19c/0x26c)
    [ 1.729644] [<c022bc40>] (bus_add_driver+0x0/0x26c) from [<c022cdcc>] (driver_register+0x80/0x138)
    [ 1.738983] [<c022cd4c>] (driver_register+0x0/0x138) from [<c022e030>] (platform_driver_register+0x5c/0x60)
    [ 1.749114] r8:00000000 r7:00000000 r6:c781c000 r5:c05fd08c r4:c0666100

    But without added ADC driver kernel loaded succesfully without panic message.Can you please tell me how to solve this issue.

    Thanks in advance.

    Regards,

    Senthil

  • Hi Senthil,

    Please attach your board config file. Thank you.

    Best regards,
    Miroslav

  • I've got a similar problem. My Kernel crash:

    [ 3.037017] Unhandled fault: external abort on non-linefetch (0x1028) at 0xf9e0d054
    [ 3.044738] Internal error: : 1028 [#1]
    [ 3.048583] Modules linked in:
    [ 3.051666] CPU: 0 Not tainted (3.2.0 #1)
    [ 3.056060] PC is at tsc_step_config_tsc+0x100/0x124
    [ 3.061065] LR is at tscadc_probe+0x28c/0x4c4

    I know that the problem happens when I'm attempting to read TSCADC_REG_SE. For example a line of code like this will cause the problem:

    tscadc_writel(ts_dev, TSCADC_REG_SE, tscadc_readl(ts_dev, TSCADC_REG_SE) | TSCADC_STPENB_STEPENB_TSC);

    but a line like this will not:

    tscadc_writel(ts_dev, TSCADC_REG_SE, TSCADC_STPENB_STEPENB_TSC);

    The problem however is that even if kernel doesn't crash, all the analogue inputs read as 0. I think the ADC clock is not running. I was getting a similar error message to  Senthil's but that was when I tried to enable the clock in a crude way like this:

    #define PRCM_MOD_EN (0x2)
    #define CM_WKUP_ADC_TSC_CLKCTRL (0xbc)

    writel(PRCM_MOD_EN, CM_WKUP_ADC_TSC_CLKCTRL);

    I also tried to enable it in a way that I've seen in an older version of the driver:

    ts_dev->tsc_ick = clk_get(&pdev->dev, "adc_tsc_ick");
    if (IS_ERR(ts_dev->tsc_ick)) {
    dev_err(&pdev->dev, "failed to get TSC ick\n");
    goto err_free_irq;
    }
    clk_enable(ts_dev->tsc_ick);

    But unfortunately that didn't have any effect.

    Miroslav, what to look for in the board config file? Any clock enable or device registering that should be there?

    Thanks,

    Arturs

  • Hi Experts,

     Herewith I have attached the board config file.if we added the {mfd_tscadc_init}, function in our board config file.we got the kernel panic message.If we are not included this function kernel loaded without panic message.please suggest me how to solve this issue.

    Thanks & Regards,

    8625.board-am335xevm.c
    /*
     * Code for AM335X EVM.
     *
     * Copyright (C) 2011 Texas Instruments, Inc. - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation version 2.
     *
     * This program is distributed "as is" WITHOUT ANY WARRANTY of any
     * kind, whether express or implied; without even the implied warranty
     * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     */
    #include <linux/kernel.h>
    #include <linux/init.h>
    #include <linux/i2c.h>
    #include <linux/module.h>
    #include <linux/i2c/at24.h>
    #include <linux/phy.h>
    #include <linux/gpio.h>
    #include <linux/spi/spi.h>
    #include <linux/spi/flash.h>
    #include <linux/gpio_keys.h>
    #include <linux/input.h>
    #include <linux/input/matrix_keypad.h>
    #include <linux/mtd/mtd.h>
    #include <linux/mtd/nand.h>
    #include <linux/mtd/partitions.h>
    #include <linux/platform_device.h>
    #include <linux/clk.h>
    #include <linux/err.h>
    #include <linux/export.h>
    #include <linux/wl12xx.h>
    #include <linux/ethtool.h>
    #include <linux/mfd/tps65910.h>
    #include <linux/mfd/tps65217.h>
    #include <linux/pwm_backlight.h>
    #include <linux/input/ti_tsc.h>
    #include <linux/mfd/ti_tscadc.h>
    #include <linux/reboot.h>
    #include <linux/pwm/pwm.h>
    #include <linux/rtc/rtc-omap.h>
    #include <linux/opp.h>
    #include <linux/ad9889b.h>
    #include <linux/i2c/pca953x.h>
    #include <linux/input/ft5x06_ts.h>
    #include <linux/mag3110.h>
    
    /* LCD controller is similar to DA850 */
    #include <video/da8xx-fb.h>
    
    #include <mach/hardware.h>
    #include <mach/board-am335xevm.h>
    
    #include <asm/mach-types.h>
    #include <asm/mach/arch.h>
    #include <asm/mach/map.h>
    #include <asm/hardware/asp.h>
    
    #include <plat/omap_device.h>
    #include <plat/irqs.h>
    #include <plat/board.h>
    #include <plat/common.h>
    #include <plat/lcdc.h>
    #include <plat/usb.h>
    #include <plat/mmc.h>
    #include <plat/emif.h>
    #include <plat/nand.h>
    
    #include <linux/platform_data/ti_adc.h>
    
    #include "board-flash.h"
    #include "cpuidle33xx.h"
    #include "mux.h"
    #include "devices.h"
    #include "hsmmc.h"
    
    /* Convert GPIO signal to GPIO pin number */
    #define GPIO_TO_PIN(bank, gpio) (32 * (bank) + (gpio))
    
    /* BBB PHY IDs */
    #define BBB_PHY_ID		0x7c0f1
    #define BBB_PHY_MASK		0xfffffffe
    
    /* AM335X EVM Phy ID and Debug Registers */
    #define AM335X_EVM_PHY_ID		0x4dd074
    #define AM335X_EVM_PHY_MASK		0xfffffffe
    #define AR8051_PHY_DEBUG_ADDR_REG	0x1d
    #define AR8051_PHY_DEBUG_DATA_REG	0x1e
    #define AR8051_DEBUG_RGMII_CLK_DLY_REG	0x5
    #define AR8051_RGMII_TX_CLK_DLY		BIT(8)
    
    static const struct display_panel disp_panel = {
    	WVGA,
    	32,
    	32,
    	COLOR_ACTIVE,
    };
    
    #define GPIO_EXP1_P7 255     
    #define GPIO_EXP1_P6 254     
    #define GPIO_EXP1_P5 253     
    #define GPIO_EXP1_P4 252     
    #define GPIO_EXP1_P3 251     
    #define GPIO_EXP1_P2 250     
    #define GPIO_EXP1_P1 249     
    #define GPIO_EXP1_P0 248     
    
    #define GPIO_TOUCH_INT GPIO_TO_PIN(1, 23)
    
    #define GPIO_EXP2_P0 128
    
    /* LCD backlight platform Data */
    #define AM335X_BACKLIGHT_MAX_BRIGHTNESS        100
    #define AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS    100
    #define AM335X_PWM_PERIOD_NANO_SECONDS        (5000 * 10)
    
    
    
    static struct platform_pwm_backlight_data am335x_backlight_data0 = {
    	.pwm_id         = "ecap.0",
    	.ch             = -1,
    	.lth_brightness	= 21,
    	.max_brightness = AM335X_BACKLIGHT_MAX_BRIGHTNESS,
    	.dft_brightness = AM335X_BACKLIGHT_DEFAULT_BRIGHTNESS,
    	.pwm_period_ns  = AM335X_PWM_PERIOD_NANO_SECONDS,
    };
    
    static struct lcd_ctrl_config lcd_cfg = {
    	&disp_panel,
    	.ac_bias		= 255,
    	.ac_bias_intrpt		= 0,
    	.dma_burst_sz		= 16,
    	.bpp			= 32,
    	.fdd			= 0x80,
    	.tft_alt_mode		= 0,
    	.stn_565_mode		= 0,
    	.mono_8bit_mode		= 0,
    	.invert_line_clock	= 1,
    	.invert_frm_clock	= 1,
    	.sync_edge		= 0,
    	.sync_ctrl		= 1,
    	.raster_order		= 0,
    };
    
    struct da8xx_lcdc_platform_data TFC_S9700RTWV35TR_01B_pdata = {
    	.manu_name		= "ThreeFive",
    	.controller_data	= &lcd_cfg,
    	.type			= "TFC_S9700RTWV35TR_01B",
    };
    
    struct da8xx_lcdc_platform_data  NHD_480272MF_ATXI_pdata = {
    	.manu_name              = "NHD",
    	.controller_data        = &lcd_cfg,
    	.type                   = "NHD-4.3-ATXI#-T-1",
    };
    
    #include "common.h"
    
    #include <linux/lis3lv02d.h>
    
    /* TSc controller */
    static struct adc_data am335x_adc_data = { 
            .adc_channels = 8,
    };
    
    static struct mfd_tscadc_board tscadc = {
        .adc_init = &am335x_adc_data,
    };
    
    static u8 am335x_iis_serializer_direction1[] = {
    	TX_MODE,		RX_MODE,		INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,
    };
    
    static struct snd_platform_data am335x_evm_snd_data1 = {
    	.tx_dma_offset	= 0x46000000,	/* McASP1 */
    	.rx_dma_offset	= 0x46000000,
    	.op_mode	= DAVINCI_MCASP_IIS_MODE,
    	.num_serializer	= ARRAY_SIZE(am335x_iis_serializer_direction1),
    	.tdm_slots	= 2,
    	.serial_dir	= am335x_iis_serializer_direction1,
    	.asp_chan_q	= EVENTQ_2,
    	.version	= MCASP_VERSION_3,
    	.txnumevt	= 1,
    	.rxnumevt	= 1,
    };
    
    static struct omap2_hsmmc_info am335x_mmc[] __initdata = {
    	{
    		.mmc            = 1,
    		.caps           = MMC_CAP_4_BIT_DATA,
    		.gpio_cd        = GPIO_TO_PIN(0, 6),
    		.gpio_wp        = GPIO_TO_PIN(3, 18),
    		.ocr_mask       = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3V3 */
    	},
    	{
    		.mmc            = 0,	/* will be set at runtime */
    	},
    	{
    		.mmc            = 0,	/* will be set at runtime */
    	},
    	{}      /* Terminator */
    };
    
    
    #ifdef CONFIG_OMAP_MUX
    static struct omap_board_mux board_mux[] __initdata = {
    	/*
    	 * Setting SYSBOOT[5] should set xdma_event_intr0 pin to mode 3 thereby
    	 * allowing clkout1 to be available on xdma_event_intr0.
    	 * However, on some boards (like EVM-SK), SYSBOOT[5] isn't properly
    	 * latched.
    	 * To be extra cautious, setup the pin-mux manually.
    	 * If any modules/usecase requries it in different mode, then subsequent
    	 * module init call will change the mux accordingly.
    	 */
    	AM33XX_MUX(XDMA_EVENT_INTR0, OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT),
    	AM33XX_MUX(I2C0_SDA, OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW |
    			AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT),
    	AM33XX_MUX(I2C0_SCL, OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW |
    			AM33XX_INPUT_EN | AM33XX_PIN_OUTPUT),
    	{ .reg_offset = OMAP_MUX_TERMINATOR },
    };
    #else
    #define	board_mux	NULL
    #endif
    
    static int am33xx_evmid = 0;
    /*
    * am335x_evm_set_id - set up board evmid
    * @evmid - evm id which needs to be configured
    *
    * This function is called to configure board evm id.
    */
    void am335x_evm_set_id(unsigned int evmid)
    {
    	am33xx_evmid = evmid;
    	return;
    }
    
    /*
    * am335x_evm_get_id - returns Board Type (EVM/BB/EVM-SK ...)
    *
    * Note:
    *	returns -EINVAL if Board detection hasn't happened yet.
    */
    int am335x_evm_get_id(void)
    {
    	return am33xx_evmid;
    }
    EXPORT_SYMBOL(am335x_evm_get_id);
    
    /* module pin mux structure */
    struct pinmux_config {
    	const char *string_name; /* signal name format */
    	int val; /* Options for the mux register value */
    };
    
    struct common_dev_cfg {
    	void (*device_init)(void);
    
    /*
    * If the device is required on both baseboard & daughter board (ex i2c),
    * specify DEV_ON_BASEBOARD
    */
    #define DEV_ON_BASEBOARD	0
    #define DEV_ON_DGHTR_BRD	1
    	u32 device_on;
    
    	u32 profile;	/* Profiles (0-7) in which the module is present */
    };
    
    static struct omap_board_config_kernel am335x_evm_config[] __initdata = {
    };
    
    static struct pinmux_config haptics_pin_mux[] = {
    	{"gpmc_ad9.ehrpwm2B",		OMAP_MUX_MODE4 |
    		AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    static struct pinmux_config adc_pin_mux[] = {
            {"ain0.ain0",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
            {"ain2.ain2",           OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
            {"vrefp.vrefp",         OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
            {"vrefn.vrefn",         OMAP_MUX_MODE0 | AM33XX_INPUT_EN},
            {NULL, 0},
    };
    
    /* Module pin mux for LCDC */
    static struct pinmux_config lcdc_pin_mux[] = {
    	{"lcd_data0.lcd_data0",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data1.lcd_data1",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data2.lcd_data2",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data3.lcd_data3",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data4.lcd_data4",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data5.lcd_data5",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data6.lcd_data6",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data7.lcd_data7",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data8.lcd_data8",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data9.lcd_data9",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data10.lcd_data10",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data11.lcd_data11",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data12.lcd_data12",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data13.lcd_data13",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data14.lcd_data14",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"lcd_data15.lcd_data15",	OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT
    						       | AM33XX_PULL_DISA},
    	{"gpmc_ad8.lcd_data16",		OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad9.lcd_data17",		OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad10.lcd_data18",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad11.lcd_data19",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad12.lcd_data20",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad13.lcd_data21",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad14.lcd_data22",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"gpmc_ad15.lcd_data23",	OMAP_MUX_MODE1 | AM33XX_PIN_OUTPUT},
    	{"lcd_vsync.lcd_vsync",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{"lcd_hsync.lcd_hsync",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{"lcd_pclk.lcd_pclk",		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{"lcd_ac_bias_en.lcd_ac_bias_en", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    /* Pin mux for nand flash module */
    static struct pinmux_config nand_pin_mux[] = {
    	{"gpmc_ad0.gpmc_ad0",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad1.gpmc_ad1",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad2.gpmc_ad2",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad3.gpmc_ad3",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad4.gpmc_ad4",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad5.gpmc_ad5",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad6.gpmc_ad6",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ad7.gpmc_ad7",	  OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_wait0.gpmc_wait0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_wpn.gpmc_wpn",	  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_csn0.gpmc_csn0",	  OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
    	{"gpmc_advn_ale.gpmc_advn_ale",  OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
    	{"gpmc_oen_ren.gpmc_oen_ren",	 OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
    	{"gpmc_wen.gpmc_wen",     OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
    	{"gpmc_ben0_cle.gpmc_ben0_cle",	 OMAP_MUX_MODE0 | AM33XX_PULL_DISA},
    	{NULL, 0},
    };
    
    static struct pinmux_config i2c1_pin_mux[] = {
    	{"spi0_d1.i2c1_sda",    OMAP_MUX_MODE2 | AM33XX_SLEWCTRL_SLOW |
    					AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
    	{"spi0_cs0.i2c1_scl",   OMAP_MUX_MODE2 | AM33XX_SLEWCTRL_SLOW |
    					AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
    	{NULL, 0},
    };
    
    /* Module pin mux for mcasp0 */
    static struct pinmux_config mcasp0_pin_mux[] = {
    	{"mcasp0_aclkx.mcasp0_aclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
    	{"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
    	{"mcasp0_axr0.mcasp0_axr0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
    	{"mcasp0_axr1.mcasp0_axr1", OMAP_MUX_MODE0 |
    						AM33XX_PIN_INPUT_PULLDOWN},
    	{NULL, 0},
    };
    
    
    /* Module pin mux for mmc0 */
    static struct pinmux_config mmc0_common_pin_mux[] = {
    	{"mmc0_dat3.mmc0_dat3",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"mmc0_dat2.mmc0_dat2",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"mmc0_dat1.mmc0_dat1",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"mmc0_dat0.mmc0_dat0",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"mmc0_clk.mmc0_clk",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"mmc0_cmd.mmc0_cmd",	OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"spi0_cs1.mmc0_sdcd",	OMAP_MUX_MODE5 | AM33XX_PIN_INPUT},
    	{"mcasp0_aclkr.mmc0_sdwp",	OMAP_MUX_MODE4 | AM33XX_PIN_INPUT },
    
    	{NULL, 0},
    };
    
    static struct pinmux_config mmc0_wp_only_pin_mux[] = {
    	{"mcasp0_aclkr.gpio3_18", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
    	{NULL, 0},
    };
    
    static struct pinmux_config mmc0_cd_only_pin_mux[] = {
    	{"spi0_cs1.gpio0_6",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT_PULLUP},
    	{NULL, 0},
    };
    
    /* Module pin mux for uart2 */
    static struct pinmux_config uart2_pin_mux[] = {
    	{"mii1_txclk.uart2_rxd", OMAP_MUX_MODE1 | AM33XX_SLEWCTRL_SLOW |
    						AM33XX_PIN_INPUT_PULLUP},
    	{"mii1_rxclk.uart2_txd", OMAP_MUX_MODE1 | AM33XX_PULL_UP |
    						AM33XX_PULL_DISA },
    	{"i2c0_sda.i2c0_sda", OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW
    						| AM33XX_PIN_INPUT_PULLUP },
    	{"i2c0_scl.i2c0_scl", OMAP_MUX_MODE0 | AM33XX_SLEWCTRL_SLOW 
    						| AM33XX_PIN_INPUT_PULLUP },
    	{NULL, 0},
    };
    
    /* Keys mapping */
    static const uint32_t am335x_evm_matrix_keys[] = {
    	KEY(0, 0, KEY_MENU),
    	KEY(1, 0, KEY_BACK),
    
    	KEY(0, 1, KEY_RIGHT),
    	KEY(1, 1, KEY_ENTER),
    };
    
    const struct matrix_keymap_data am335x_evm_keymap_data = {
    	.keymap      = am335x_evm_matrix_keys,
    	.keymap_size = ARRAY_SIZE(am335x_evm_matrix_keys),
    };
    
    static const unsigned int am335x_evm_keypad_row_gpios[] = {
    	250, 251
    };
    
    static const unsigned int am335x_evm_keypad_col_gpios[] = {
    	248,249
    };
    /* pinmux for keypad device */
    static struct pinmux_config volume_keys_pin_mux[] = {
            {"spi0_sclk.gpio0_2",  OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
            {"spi0_d0.gpio0_3",    OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
            {NULL, 0},
    };
    
    /* Configure GPIOs for Volume Keys */
    static struct gpio_keys_button joysrick_buttons[] = {
            {
                    .code                   = KEY_BACK,
                    .gpio                   = 57,   //GPIO_EXP1_P7,
                    .active_low             = true,
                    .desc                   = "LEFT",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
             //        .debounce_interval      = 30,
    
            },
            {
                    .code                   = KEY_DOWN,
                    .gpio                   = 260,     //GPIO_EXP1_P6,
                    .active_low             = true,
                    .desc                   = "DOWN",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
           //           .debounce_interval      = 30,
    
            },
     /*       {
                    .code                   = KEY_MENU,
                    .gpio                   = GPIO_EXP1_P5,
                    .active_low             = true,
                    .desc                   = "UP",
                     .debounce_interval      = 30,
    
                    .type                   = EV_KEY,
                     .wakeup                 = 1,
            },  
            {
                    .code                   = KEY_RIGHT,
                    .gpio                   = GPIO_EXP1_P4,
                    .active_low             = true,
                    .desc                   = "RIGHT", 
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },   
            {
                    .code                   = KEY_ENTER,
                    .gpio                   = GPIO_EXP1_P3,
                    .active_low             = true,
                    .desc                   = "ENTER", 
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },   
            {
                    .code                   = KEY_UP,
                    .gpio                   = GPIO_EXP1_P1,
                    .active_low             = false,
                    .desc                   = "SW_PROG_1",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },
           {
                    .code                   = KEY_UP,
                    .gpio                   = GPIO_EXP1_P0,
                    .active_low             = false,
                    .desc                   = "SW_PROG_2",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },
    
    */
    };
    
    static struct gpio_keys_platform_data joysrick_info = {
            .buttons        = joysrick_buttons,
            .nbuttons       = ARRAY_SIZE(joysrick_buttons),
    };
    
    
    
    static struct platform_device joysrick = {
            .name   = "gpio-keysss",
            .id     = -1,
            .dev    = {
                    .platform_data  = &joysrick_info,
            },
    };
    
    
    /* Configure GPIOs for GPIO Keys */
    static struct gpio_keys_button am335x_evm_gpio_buttons[] = {
     {
                    .code                   = KEY_LEFT,
                    .gpio                   = GPIO_EXP1_P7,
                    .active_low             = false,
                    .desc                   = "LEFT",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
             //        .debounce_interval      = 30,
    
            },
            {
                    .code                   = KEY_DOWN,
                    .gpio                   =  GPIO_EXP1_P6,
                    .active_low             = false,
                    .desc                   = "DOWN",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
           //           .debounce_interval      = 30,
    
            },
            {
                    .code                   = KEY_UP,
                    .gpio                   = GPIO_EXP1_P5,
                    .active_low             = false,
                    .desc                   = "UP",
                     .debounce_interval      = 30,
    
                    .type                   = EV_KEY,
                     .wakeup                 = 1,
            },  
            {
                    .code                   = KEY_RIGHT,
                    .gpio                   = GPIO_EXP1_P4,
                    .active_low             = false,
                    .desc                   = "RIGHT", 
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },   
            {
                    .code                   = KEY_ENTER,
                    .gpio                   = GPIO_EXP1_P3,
                    .active_low             = false,
                    .desc                   = "ENTER", 
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },   
            {
                    .code                   = KEY_BACK,
                    .gpio                   = GPIO_EXP1_P1,
                    .active_low             = false,
                    .desc                   = "SW_PROG_1",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },
             {
                    .code                   = KEY_MENU,
                    .gpio                   = GPIO_EXP1_P0,
                    .active_low             = false,
                    .desc                   = "SW_PROG_2",
                    .type                   = EV_KEY,
                    .wakeup                 = 1,
            },
    
    
    };
    
    static struct gpio_keys_platform_data am335x_evm_gpio_key_info = {
    	.buttons        = am335x_evm_gpio_buttons,
    	.nbuttons       = ARRAY_SIZE(am335x_evm_gpio_buttons),
    };
    
    static struct platform_device am335x_evm_gpio_keys = {
    	.name   = "gpio-keys",
    	.id     = -1,
    	.dev    = {
    		.platform_data  = &am335x_evm_gpio_key_info,
    	},
    };
    
    
    
    
    static void gpio_keys_init(void)
    {
    	int err;
    
    //	setup_pin_mux(gpio_keys_pin_mux);
    	err = platform_device_register(&am335x_evm_gpio_keys);
    	if (err)
    		pr_err("failed to register gpio key device\n");
    }
    /*
    * @pin_mux - single module pin-mux structure which defines pin-mux
    *			details for all its pins.
    */
    static void setup_pin_mux(struct pinmux_config *pin_mux)
    {
    	int i;
    
    	for (i = 0; pin_mux->string_name != NULL; pin_mux++)
    		omap_mux_init_signal(pin_mux->string_name, pin_mux->val);
    
    }
    
    static void _configure_device(struct common_dev_cfg *dev_cfg)
    {	
    	int i;
    	for (i = 0; dev_cfg->device_init != NULL; dev_cfg++) 
    	{
    		dev_cfg->device_init();
    	}
    }
    
    
    /* pinmux for usb0 drvvbus */
    static struct pinmux_config usb0_pin_mux[] = {
    	{"usb0_drvvbus.usb0_drvvbus",    OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    /* pinmux for usb1 drvvbus */
    static struct pinmux_config usb1_pin_mux[] = {
    	{"usb1_drvvbus.usb1_drvvbus",    OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    
    /* Module pin mux for eCAP0 */
    static struct pinmux_config ecap0_pin_mux[] = {
    	{"ecap0_in_pwm0_out.ecap0_in_pwm0_out",
    		OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    
    #define AM335XEVM_WLAN_PMENA_GPIO	GPIO_TO_PIN(1, 30)
    #define AM335XEVM_WLAN_IRQ_GPIO		GPIO_TO_PIN(3, 17)
    #define AM335XEVM_SK_WLAN_IRQ_GPIO      GPIO_TO_PIN(0, 31)
    
    struct wl12xx_platform_data am335xevm_wlan_data = {
    	.irq = OMAP_GPIO_IRQ(AM335XEVM_WLAN_IRQ_GPIO),
    	.board_ref_clock = WL12XX_REFCLOCK_38_XTAL, /* 38.4Mhz */
    	.bt_enable_gpio = GPIO_TO_PIN(1, 30),
    	.wlan_enable_gpio = GPIO_TO_PIN(1, 9),
    };
    
    /* Module pin mux for wlan and bluetooth */
    static struct pinmux_config mmc2_wl12xx_pin_mux[] = {
    	{"gpmc_a1.mmc2_dat0", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_a2.mmc2_dat1", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_a3.mmc2_dat2", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_ben1.mmc2_dat3", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_csn3.mmc2_cmd", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{"gpmc_clk.mmc2_clk", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP},
    	{NULL, 0},
    };
    
    static struct pinmux_config uart1_wl12xx_pin_mux[] = {
    	{"uart1_ctsn.uart1_ctsn", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
    	{"uart1_rtsn.uart1_rtsn", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT},
    	{"uart1_rxd.uart1_rxd", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLUP},
    	{"uart1_txd.uart1_txd", OMAP_MUX_MODE0 | AM33XX_PULL_ENBL},
    	{NULL, 0},
    };
    
    static struct pinmux_config wl12xx_pin_mux[] = {
            {"uart0_rtsn.gpio1_9", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},   /* GPIO_WL_EN */
            {"mii1_txen.gpio3_3", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},           /* GPIO_I2C_EXP_INT2 */  
            {"gpmc_csn1.gpio1_30", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},   /* GPIO_BT_EN */
            {NULL, 0},
     }; 
    
    static struct pinmux_config other_gpio_pin_mux[] = {
            {"mii1_rxdv.gpio3_4",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},      /* MAIN_ON_OFF_SW */
    //        {"xdma_event_intr1.clkout2",OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
            {"spi0_d0.gpio0_3",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT },		/* GPIO_GPS_TIMEMARK */
            {"mii1_crs.gpio3_1",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT },        /* GPIO_I2C_EXP_INT1 */
            //{"mii1_txen.gpio3_3",OMAP_MUX_MODE7 | AM33XX_PIN_INPUT },	/* GPIO_I2C_EXP_INT2 */
            {"mii1_txd0.gpio0_28",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP }, /* GPIO_LCD_STBY */
            {"gpmc_a10.gpio1_26",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},    /* GPIO_PAL_NTSC */
            //{"gpmc_csn1.gpio1_30",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},    /* GPIO_BT_EN */
            //{"uart0_rtsn.gpio1_9",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},    /* GPIO_WL_EN */
            {NULL, 0},
    };
    
    static struct pinmux_config uart3_pin_mux[] = {
            {"mii1_rxd3.uart3_rxd", OMAP_MUX_MODE1 | AM33XX_SLEWCTRL_SLOW |
                                                    AM33XX_PIN_INPUT_PULLUP},
            {"mii1_rxd2.uart3_txd", OMAP_MUX_MODE1 | AM33XX_PULL_UP |
                                                    AM33XX_PULL_DISA |
                                                    AM33XX_SLEWCTRL_SLOW},
            {NULL, 0},
    };
    
    /* Module pin mux for uart4 */
    static struct pinmux_config uart4_pin_mux[] = {
            {"mii1_txd3.uart4_rxd", OMAP_MUX_MODE3 | AM33XX_SLEWCTRL_SLOW |
                                                    AM33XX_PIN_INPUT_PULLUP},
            {"mii1_txd2.uart4_txd", OMAP_MUX_MODE3 | AM33XX_PULL_UP | AM33XX_PULL_DISA | AM33XX_SLEWCTRL_SLOW},
            {"mii1_rxerr.gpio3_2",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},    /* GPIO_GPS_ON_OFF */
            {NULL, 0},
    };
    
    static struct pinmux_config uart5_pin_mux[] = {
            {"mii1_col.uart5_rxd", OMAP_MUX_MODE3 | AM33XX_PIN_INPUT_PULLUP}, /* H16 ZCZ Ball, GPIO3_0 */
            {"rmii1_refclk.uart5_txd", OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
            {NULL, 0},
    };
    
    static struct pinmux_config gpio_3g_mux[] = {
            {"mcasp0_ahclkr.gpio3_17",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP}, /* GPIO_3G_NRESET */
            {"mcasp0_fsr.gpio3_19",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP}, /* GPIO_3G_WAKEUP_IN */
            {"spi0_sclk.gpio0_2",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},   /* GPIO_3G_POWER_ON */
            {NULL, 0},
    };
    
    static struct pinmux_config rs485_pin_mux[] = {
            {"mii1_rxd1.gpio2_20",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},	/* RS_232_RS_485_EN2 */
            {"mii1_rxd0.gpio2_21",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},      /* RS_232_RS_485_EN1 */
            {NULL, 0},
    };
    
    static struct pinmux_config buzzer_pin_mux[] = {
            {"uart0_ctsn.gpio1_8",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},	/* GPIO_BUZZER */
            {NULL, 0},
    };
    
    static struct pinmux_config composite_hdmi_pin_mux[] = {
            {"gpmc_a5.gpio1_21", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},	/* GPIO_COMPO_EN */
            {"mii1_txd1.gpio0_21", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},	/* GPIO_HDMI_EN */
            {"gpmc_a10.gpio1_26", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},   // i added to pal_ntsc
            {"mdio_clk.gpio0_1", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},       /* GPIO_HDMI_PD */
            {"mcasp0_ahclkx.gpio3_21", OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT}, /* GPIO_BT869_PDN */
            {"gpmc_csn2.gpio1_31", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},	/* GPIO_HPD_P */
            {"mdio.gpio0_0", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT | AM33XX_PIN_OUTPUT},  /* GPIO_CEC_P */
            {NULL, 0},
    
    };
    
    static struct pinmux_config pmic_pin_mux[] = {
            {"gpmc_a0.gpio1_16",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},	/* PIMC_SLEEP */
            {"xdma_event_intr0.xdma_event_intr0",OMAP_MUX_MODE0 | AM33XX_PIN_INPUT},
            {NULL, 0},
    };
    
    static struct pinmux_config powerled_pin_mux[] = {
            {"gpmc_a6.gpio1_22",OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT},	/* POWER_LED */
            {NULL, 0},
    };
    struct ft5x0x_ts_platform_data tsc_platform= {
           // .intr=OMAP_GPIO_IRQ(GPIO_TO_PIN(1, 23)),           /* irq number   */
              .intr=OMAP_GPIO_IRQ(GPIO_TOUCH_INT),   
    };
    static struct pinmux_config tsc_pin_mux[] = {
    	{"gpmc_a7.gpio1_23", OMAP_MUX_MODE7 | AM33XX_PIN_INPUT},
            {"gpmc_a4.gpio1_20",         OMAP_MUX_MODE7 | AM33XX_PIN_OUTPUT_PULLUP},
            {NULL, 0},
    };
    
    static struct pinmux_config uart0_pin_mux[] = {
            {"uart0_rxd.uart0_rxd", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT},
            {"uart0_txd.uart0_txd", OMAP_MUX_MODE0 | AM33XX_PIN_OUTPUT},
            {NULL, 0},
    };
    
    
    static bool backlight_enable;
    
    static void enable_ecap0(void)
    {
    	backlight_enable = true;
    	setup_pin_mux(ecap0_pin_mux);
    }
    
    /* Setup pwm-backlight */
    static struct platform_device am335x_backlight = {
    	.name           = "pwm-backlight",
    	.id             = -1,
    	.dev		= {
    		.platform_data = &am335x_backlight_data0,
    	},
    };
    
    static struct pwmss_platform_data  pwm_pdata[3] = {
    	{
    		.version = PWM_VERSION_1,
    	},
    	{
    		.version = PWM_VERSION_1,
    	},
    	{
    		.version = PWM_VERSION_1,
    	},
    };
    
    static int __init backlight_init(void)
    {
    	int status = 0;
    
    	if (backlight_enable) {
    		int ecap_index = 0;
    		
    		am33xx_register_ecap(ecap_index, &pwm_pdata[ecap_index]);
    		platform_device_register(&am335x_backlight);
    	}
    	return status;
    }
    late_initcall(backlight_init);
    
    static int __init conf_disp_pll(int rate)
    {
    	struct clk *disp_pll;
    	int ret = -EINVAL;
    
    	disp_pll = clk_get(NULL, "dpll_disp_ck");
    	if (IS_ERR(disp_pll)) {
    		pr_err("Cannot clk_get disp_pll\n");
    		goto out;
    	}
    
    	ret = clk_set_rate(disp_pll, rate);
    	clk_put(disp_pll);
    out:
    	return ret;
    }
    
    static void lcdc_init(void)
    {
    	struct da8xx_lcdc_platform_data *lcdc_pdata;
    	setup_pin_mux(lcdc_pin_mux);
    
    	if (conf_disp_pll(300000000)) {
    		pr_info("Failed configure display PLL, not attempting to"
    				"register LCDC\n");
    		return;
    	}	
    	lcdc_pdata = &TFC_S9700RTWV35TR_01B_pdata;
    	if (am33xx_register_lcdc(lcdc_pdata))
    		pr_info("Failed to register LCDC device\n");
    
    	return;
    }
    
    static void mfd_tscadc_init(void)
    {
    	int err;
    	setup_pin_mux(adc_pin_mux);
    
    	err = am33xx_register_mfd_tscadc(&tscadc);
    	if (err)
    		pr_err("failed to register touchscreen device\n");
    }
    
    static void usb0_init(void)
    {
    	setup_pin_mux(usb0_pin_mux);
    	return;
    }
    
    static void usb1_init(void)
    {
    	setup_pin_mux(usb1_pin_mux);
    	return;
    }
    
    /* setup uart3 */
    static void uart3_init(void)
    {
    	setup_pin_mux(uart3_pin_mux);
    	return;
    }
    
    /* setup uart2 */
    static void uart2_init(void)
    {
    	setup_pin_mux(uart2_pin_mux);
    	return;
    }
    
    /* Setup McASP 0 */
    static void mcasp0_init(void)
    {
    	/* Configure McASP */
    	setup_pin_mux(mcasp0_pin_mux);
    	am335x_register_mcasp(&am335x_evm_snd_data1, 1);
    	return;
    }
    
    
    
    /* setup haptics */
    #define HAPTICS_MAX_FREQ 250
    static void haptics_init(void)
    {
    	setup_pin_mux(haptics_pin_mux);
    	pwm_pdata[2].chan_attrib[1].max_freq = HAPTICS_MAX_FREQ;
    	am33xx_register_ehrpwm(2, &pwm_pdata[2]);
    }
    
    /* NAND partition information */
    static struct mtd_partition am335x_nand_partitions[] = {
    /* All the partition sizes are listed in terms of NAND block size */
    	{
    		.name           = "SPL",
    		.offset         = 0,			/* Offset = 0x0 */
    		.size           = SZ_128K,
    	},
    	{
    		.name           = "SPL.backup1",
    		.offset         = MTDPART_OFS_APPEND,	/* Offset = 0x20000 */
    		.size           = SZ_128K,
    	},
    	{
    		.name           = "SPL.backup2",
    		.offset         = MTDPART_OFS_APPEND,	/* Offset = 0x40000 */
    		.size           = SZ_128K,
    	},
    	{
    		.name           = "SPL.backup3",
    		.offset         = MTDPART_OFS_APPEND,	/* Offset = 0x60000 */
    		.size           = SZ_128K,
    	},
    	{
    		.name           = "U-Boot",
    		.offset         = MTDPART_OFS_APPEND,   /* Offset = 0x80000 */
    		.size           = 15 * SZ_128K,
    	},
    	{
    		.name           = "U-Boot Env",
    		.offset         = MTDPART_OFS_APPEND,   /* Offset = 0x260000 */
    		.size           = 1 * SZ_128K,
    	},
    	{
    		.name           = "Kernel",
    		.offset         = MTDPART_OFS_APPEND,   /* Offset = 0x280000 */
    		.size           = 40 * SZ_128K,
    	},
    	{
    		.name           = "File System",
    		.offset         = MTDPART_OFS_APPEND,   /* Offset = 0x780000 */
    		.size           = MTDPART_SIZ_FULL,
    	},
    };
    
    
    static struct gpmc_timings am335x_nand_timings = {
    	.sync_clk = 0,
    
    	.cs_on = 0,
    	.cs_rd_off = 44,
    	.cs_wr_off = 44,
    
    	.adv_on = 6,
    	.adv_rd_off = 34,
    	.adv_wr_off = 44,
    	.we_off = 40,
    	.oe_off = 54,
    
    	.access = 64,
    	.rd_cycle = 82,
    	.wr_cycle = 82,
    
    	.wr_access = 40,
    	.wr_data_mux_bus = 0,
    };
    
    static void evm_nand_init(void)
    {
    	struct omap_nand_platform_data *pdata;
    	struct gpmc_devices_info gpmc_device[2] = {
    		{ NULL, 0 },
    		{ NULL, 0 },
    	};
    
    	setup_pin_mux(nand_pin_mux);
    	pdata = omap_nand_init(am335x_nand_partitions,
    		ARRAY_SIZE(am335x_nand_partitions), 0, 0,
    		&am335x_nand_timings);
    	if (!pdata)
    		return;
    	pdata->ecc_opt =OMAP_ECC_BCH8_CODE_HW;
    	pdata->elm_used = true;
    	gpmc_device[0].pdata = pdata;
    	gpmc_device[0].flag = GPMC_DEVICE_NAND;
    
    	omap_init_gpmc(gpmc_device, sizeof(gpmc_device));
    	omap_init_elm();
    }
    
    
    static struct lis3lv02d_platform_data lis331dlh_pdata = {
    	.click_flags = LIS3_CLICK_SINGLE_X |
    			LIS3_CLICK_SINGLE_Y |
    			LIS3_CLICK_SINGLE_Z,
    	.wakeup_flags = LIS3_WAKEUP_X_LO | LIS3_WAKEUP_X_HI |
    			LIS3_WAKEUP_Y_LO | LIS3_WAKEUP_Y_HI |
    			LIS3_WAKEUP_Z_LO | LIS3_WAKEUP_Z_HI,
    	.irq_cfg = LIS3_IRQ1_CLICK | LIS3_IRQ2_CLICK,
    	.wakeup_thresh	= 10,
    	.click_thresh_x = 10,
    	.click_thresh_y = 10,
    	.click_thresh_z = 10,
    	.g_range	= 2,
    	.st_min_limits[0] = 120,
    	.st_min_limits[1] = 120,
    	.st_min_limits[2] = 140,
    	.st_max_limits[0] = 550,
    	.st_max_limits[1] = 550,
    	.st_max_limits[2] = 750,
    };
    
    static struct i2c_board_info lis331dlh_i2c_boardinfo[] = {
    	{
    		I2C_BOARD_INFO("lis331dlh", 0x18),
    		.platform_data = &lis331dlh_pdata,
    	},
    };
    
    static void lis331dlh_init(void)
    {
    	struct i2c_adapter *adapter;
    	struct i2c_client *client;
    	unsigned int i2c_instance;
    
    	
    	i2c_instance = 2;
    	
    
    	/* I2C adapter request */
    	adapter = i2c_get_adapter(i2c_instance);
    	if (!adapter) {
    		pr_err("failed to get adapter i2c%u\n", i2c_instance);
    		return;
    	}
    
    	client = i2c_new_device(adapter, lis331dlh_i2c_boardinfo);
    	if (!client)
    		pr_err("failed to register lis331dlh to i2c%u\n", i2c_instance);
    
    	i2c_put_adapter(adapter);
    }
    
    static struct ad9889b_pdata ad9889b_data = {
            .irq_gpio=GPIO_EXP2_P0,
    };
    static struct mxc_mag3110_platform_data mag3110_data = {
      	.int1 = 132, // eCOMPASS_INT is gpio for interrupt
    
    };
    
    static struct i2c_board_info am335x_i2c1_boardinfo[] = {
    	{
                    I2C_BOARD_INFO("usb2512b", 0x58),
            },
    	{
                    I2C_BOARD_INFO("ad9889b", 0x3d),
                    .platform_data = &ad9889b_data,
            },
            {
                     I2C_BOARD_INFO("ft5x0x_ts", 0x38),
                    .irq = OMAP_GPIO_IRQ(GPIO_TOUCH_INT),
            },
            {
                    I2C_BOARD_INFO("bt869", 0x44),
            },
            {
                    I2C_BOARD_INFO("pca9554", 0x20),
                    //.platform_data = &am335x_i2c_pca9554_platdata1,
                    //.irq = OMAP_GPIO_IRQ(GPIO_EXP1_INT),
            },
            {
                    I2C_BOARD_INFO("pca9554", 0x24),
                    //.platform_data = &am335x_i2c_pca9554_platdata2,
                    //.irq = OMAP_GPIO_IRQ(GPIO_EXP2_INT),
            },
            {
                    I2C_BOARD_INFO("lis331dlh", 0x19),
            },
            {
                    I2C_BOARD_INFO("tlv320aic3x", 0x1b),
            },
            {
                    I2C_BOARD_INFO("mag3110", 0x0E),
                    .platform_data = &mag3110_data,
            },
    	{
                    I2C_BOARD_INFO("tmp275", 0x48),
            },
    
    };
    
    static void i2c1_init(void)
    {
    	setup_pin_mux(i2c1_pin_mux);
    	omap_register_i2c_bus(2, 100, am335x_i2c1_boardinfo,
    			ARRAY_SIZE(am335x_i2c1_boardinfo));
    	return;
    }
    
    static void mmc2_wl12xx_init(void)
    {
    	setup_pin_mux(mmc2_wl12xx_pin_mux);
    
    	am335x_mmc[1].mmc = 3;
    	am335x_mmc[1].name = "wl1271";
    	am335x_mmc[1].caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD;
    	am335x_mmc[1].nonremovable = true;
    	am335x_mmc[1].gpio_cd = -EINVAL;
    	am335x_mmc[1].gpio_wp = -EINVAL;
    	am335x_mmc[1].ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34; /* 3V3 */
    
    	/* mmc will be initialized when mmc0_init is called */
    	return;
    }
    
    static void uart1_wl12xx_init(void)
    {
    	setup_pin_mux(uart1_wl12xx_pin_mux);
    }
    
    static void wl12xx_bluetooth_enable(void)
    {
    	int status = gpio_request(am335xevm_wlan_data.bt_enable_gpio,
    		"bt_en\n");
    	if (status < 0)
    		pr_err("Failed to request gpio for bt_enable");
    
    	pr_info("Configure Bluetooth Enable pin...\n");
    	gpio_direction_output(am335xevm_wlan_data.bt_enable_gpio, 0);
    }
    
    #define AM33XX_CTRL_REGADDR(reg)					\
    		AM33XX_L4_WK_IO_ADDRESS(AM33XX_SCM_BASE + (reg))
    
    /* wlan enable pin */
    #define AM33XX_CONTROL_PADCONF_GPMC_CSN0_OFFSET		0x087C
    static int wl12xx_set_power(struct device *dev, int slot, int on, int vdd)
    {
    	//int pad_mux_value;
    
    	if (on) {
    		gpio_direction_output(am335xevm_wlan_data.wlan_enable_gpio, 1);
    
    
    		mdelay(70);
    	} else {
    		gpio_direction_output(am335xevm_wlan_data.wlan_enable_gpio, 0);
    	}
    
    	return 0;
    }
    
    static void wl12xx_init(void)
    {
    	struct device *dev;
    	struct omap_mmc_platform_data *pdata;
    	int ret;
    	setup_pin_mux(wl12xx_pin_mux);
    	am335xevm_wlan_data.platform_quirks = WL12XX_PLATFORM_QUIRK_EDGE_IRQ;
    	wl12xx_bluetooth_enable();
    
    	if (wl12xx_set_platform_data(&am335xevm_wlan_data))
    		pr_err("error setting wl12xx data\n");
    
    	dev = am335x_mmc[1].dev;
    	if (!dev) {
    		pr_err("wl12xx mmc device initialization failed\n");
    		goto out;
    	}
    
    	pdata = dev->platform_data;
    	if (!pdata) {
    		pr_err("Platfrom data of wl12xx device not set\n");
    		goto out;
    	}
    
    	ret = gpio_request_one(am335xevm_wlan_data.wlan_enable_gpio,
    		GPIOF_OUT_INIT_LOW, "wlan_en");
    	if (ret) {
    		pr_err("Error requesting wlan enable gpio: %d\n", ret);
    		goto out;
    	}
    
    
    	pdata->slots[0].set_power = wl12xx_set_power;
    out:
    	return;
    }
    
    static void mmc0_init(void)
    {
    	setup_pin_mux(mmc0_common_pin_mux);
    	setup_pin_mux(mmc0_cd_only_pin_mux);
    	setup_pin_mux(mmc0_wp_only_pin_mux);
    	
    	omap2_hsmmc_init(am335x_mmc);
    	return;
    }
    
    
    static void mmc0_no_cd_init(void)
    {
    	setup_pin_mux(mmc0_common_pin_mux);
    	setup_pin_mux(mmc0_wp_only_pin_mux);
    
    //	omap2_hsmmc_init(am335x_mmc);
    	return;
    }
    
    static struct omap_rtc_pdata am335x_rtc_info = {
    	.pm_off		= false,
    	.wakeup_capable	= 0,
    };
    
    static void am335x_rtc_init(void)
    {
    	void __iomem *base;
    	struct clk *clk;
    	struct omap_hwmod *oh;
    	struct platform_device *pdev;
    	char *dev_name = "am33xx-rtc";
    
    	clk = clk_get(NULL, "rtc_fck");
    	if (IS_ERR(clk)) {
    		pr_err("rtc : Failed to get RTC clock\n");
    		return;
    	}
    
    	if (clk_enable(clk)) {
    		pr_err("rtc: Clock Enable Failed\n");
    		return;
    	}
    
    	base = ioremap(AM33XX_RTC_BASE, SZ_4K);
    
    	if (WARN_ON(!base))
    		return;
    
    	/* Unlock the rtc's registers */
    	writel(0x83e70b13, base + 0x6c);
    	writel(0x95a4f1e0, base + 0x70);
    
    	/*
    	 * Enable the 32K OSc
    	 * TODO: Need a better way to handle this
    	 * Since we want the clock to be running before mmc init
    	 * we need to do it before the rtc probe happens
    	 */
    	writel(0x48, base + 0x54);
    
    	iounmap(base);
    
    	clk_disable(clk);
    	clk_put(clk);
    
    	if (omap_rev() == AM335X_REV_ES2_0)
    		am335x_rtc_info.wakeup_capable = 1;
    
    	oh = omap_hwmod_lookup("rtc");
    	if (!oh) {
    		pr_err("could not look up %s\n", "rtc");
    		return;
    	}
    
    	pdev = omap_device_build(dev_name, -1, oh, &am335x_rtc_info,
    			sizeof(struct omap_rtc_pdata), NULL, 0, 0);
    	WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
    			dev_name, oh->name);
    }
    
    /* Enable clkout2 */
    static struct pinmux_config clkout2_pin_mux[] = {
    	{"xdma_event_intr1.clkout2", OMAP_MUX_MODE3 | AM33XX_PIN_OUTPUT},
    	{NULL, 0},
    };
    
    static void clkout2_enable(void)
    {
    	struct clk *ck_32;
    
    	ck_32 = clk_get(NULL, "clkout2_ck");
    	if (IS_ERR(ck_32)) {
    		pr_err("Cannot clk_get ck_32\n");
    		return;
    	}
    
    	clk_enable(ck_32);
    
    	setup_pin_mux(clkout2_pin_mux);
    }
    
    static void uart4_init(void)
    {
            setup_pin_mux(uart4_pin_mux);
            return;
    }
    static void uart5_init(void)
    {
            setup_pin_mux(uart5_pin_mux);
            return;
    }
    static void gpio_3g_init(void)
    {
            setup_pin_mux(gpio_3g_mux);
            return;
    }
    static void rs485_init(void)
    {
            setup_pin_mux(rs485_pin_mux);
            return;
    }
    static void buzzer_init(void)
    {
            setup_pin_mux(buzzer_pin_mux);
            return;
    }
    static void composite_hdmi_init(void)
    {
    	setup_pin_mux(composite_hdmi_pin_mux);
    	gpio_request(117, "COMPOSITE SLEEP");
    	gpio_direction_output(117,0);
    	// for hdmi 0x3d and 0x39     
    	gpio_request(1, "HDMI_PD ");
    	gpio_direction_output(1,1);
    	gpio_request(21, "HDMI_EN ");
    	gpio_direction_output(21,0);
    	gpio_request(53, "COMP_EN ");
    	gpio_direction_output(53,0);
    	return;
    }
    static void pmic_init(void)
    {
            setup_pin_mux(pmic_pin_mux);
            return;
    }
    static void powerled_init(void)
    {
            setup_pin_mux(powerled_pin_mux);
            return;
    }
    
    /* Huawei 3G GSM Module 
     * Part NO: MU509-B
     */
    
    static void mu509b_init(void)
    {
    	int ret;
    	
    	ret = gpio_request( GPIO_TO_PIN(3, 17), "mu509b_reset");	
    	if (ret) {
                    pr_err("Error requesting MU509-B 3G Module reset pin: GPIO3_17 ");
                    goto out;
            }
    
    	ret = gpio_request( GPIO_TO_PIN(0, 2), "mu509b_power_on_off");
            if (ret) {
                    pr_err("Error requesting MU509-B 3G Module power ON/OFF pin: GPIO0_2 ");
                    goto out;
            }
    
    	ret = gpio_request( GPIO_TO_PIN(3, 19), "mu509b_wakeupin");
            if (ret) {
                    pr_err("Error requesting MU509-B 3G Module reset pin: GPIO3_17 ");
                    goto out;
            }
    	
    	 /*
             * Used for making 3G module ON and OFF
             * If the POWER_ON_OFF pin is pulled down for at least 0.5s,
             * the module is powered on; if the POWER_ON_OFF pin is
             * pulled down for at least 2.5s again, the module is powered off.
             */
    
    	gpio_direction_output(GPIO_TO_PIN(0, 2),1);
    	mdelay(50);	
    	gpio_direction_output(GPIO_TO_PIN(0, 2),0);
    	mdelay(70);
    	gpio_direction_output(GPIO_TO_PIN(0, 2),1);
    
    
    	mdelay(10);
    	
    	gpio_direction_output(GPIO_TO_PIN(3, 17),1);
    	mdelay(50);
    	gpio_direction_output(GPIO_TO_PIN(3, 17),0);
    	mdelay(70);
    	gpio_direction_output(GPIO_TO_PIN(3, 17),1);
    	
    	mdelay(10);
    
    	gpio_direction_output(GPIO_TO_PIN(3, 19),1);	
    
    out:
    	return;
    }
    static void other_gpio_init(void)
    {
            setup_pin_mux(other_gpio_pin_mux);
            return;
    }
    
    static void uart0_init(void)
    {
            setup_pin_mux(uart0_pin_mux);
            return;
    }
    static void joysrick_init(void)
    {
            int err;
    
            setup_pin_mux(volume_keys_pin_mux);
        //  platform_add_devices(&am335x_evm_volume_keys,ARRAY_SIZE(&am335x_evm_volume_keys));
    
            err = platform_device_register(&joysrick);
            if (err)
                    pr_err("failed to register matrix keypad (2x3) device\n");
            else
                  printk("gpio-keys registeredd\n");
    }
    static void tsc_init(void)
    {
            setup_pin_mux(tsc_pin_mux);
    	return;
    }
    
    /* General Purpose EVM */
    static struct common_dev_cfg hejlij_dev_cfg[] = {
    	{enable_ecap0},
    	{lcdc_init},
    	{tsc_init},
    	{mfd_tscadc_init},
    	{usb0_init},
    	{usb1_init},
    	{evm_nand_init},
    	{i2c1_init},
    	{lis331dlh_init},
    	{mcasp0_init},
    	{mmc2_wl12xx_init},
    	{mmc0_init},
    	{mmc0_no_cd_init},
    	{uart1_wl12xx_init},
    	{wl12xx_init},
    	{uart0_init},
    	{uart4_init},
    	{uart2_init},
    	{haptics_init},
    	{uart5_init},
    	{gpio_3g_init},
    	{uart3_init},
    	{rs485_init},
    	{buzzer_init},
    	{composite_hdmi_init},
    	{pmic_init},
    	{powerled_init},
    	{gpio_keys_init},
    	{joysrick_init}, 
    	{mu509b_init},
    	{other_gpio_init},
    	{NULL, 0, 0},
    
    };
    
    
    static int am33xx_evm_tx_clk_dly_phy_fixup(struct phy_device *phydev)
    {
    	phy_write(phydev, AR8051_PHY_DEBUG_ADDR_REG,
    		  AR8051_DEBUG_RGMII_CLK_DLY_REG);
    	phy_write(phydev, AR8051_PHY_DEBUG_DATA_REG, AR8051_RGMII_TX_CLK_DLY);
    
    	return 0;
    }
    
    static void setup_hejlij_board(void)
    {
    	pr_info("The board is industrial purpose HEJLIJ \n");
    
    	_configure_device(hejlij_dev_cfg);
    
    	am33xx_cpsw_init(AM33XX_CPSW_MODE_RGMII, NULL, NULL);
    	/* Atheros Tx Clk delay Phy fixup */
    	phy_register_fixup_for_uid(AM335X_EVM_PHY_ID, AM335X_EVM_PHY_MASK,
    				   am33xx_evm_tx_clk_dly_phy_fixup);
    
    }
    
    static void am335x_evm_setup(void)
    {
    	pr_info("Board name: HEJLIJ");
    	pr_info("Board version: 1.0");
    	setup_hejlij_board();
    }
    
    
    static struct regulator_init_data am335x_dummy = {
    	.constraints.always_on	= true,
    };
    
    static struct regulator_consumer_supply am335x_vdd1_supply[] = {
    	REGULATOR_SUPPLY("vdd_mpu", NULL),
    };
    
    static struct regulator_init_data am335x_vdd1 = {
    	.constraints = {
    		.min_uV			= 600000,
    		.max_uV			= 1500000,
    		.valid_modes_mask	= REGULATOR_MODE_NORMAL,
    		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE,
    		.always_on		= 1,
    	},
    	.num_consumer_supplies	= ARRAY_SIZE(am335x_vdd1_supply),
    	.consumer_supplies	= am335x_vdd1_supply,
    	.ignore_check_consumers = 1,
    };
    
    static struct regulator_consumer_supply am335x_vdd2_supply[] = {
    	REGULATOR_SUPPLY("vdd_core", NULL),
    };
    
    static struct regulator_init_data am335x_vdd2 = {
    	.constraints = {
    		.min_uV			= 600000,
    		.max_uV			= 1500000,
    		.valid_modes_mask	= REGULATOR_MODE_NORMAL,
    		.valid_ops_mask		= REGULATOR_CHANGE_VOLTAGE,
    		.always_on		= 1,
    	},
    	.num_consumer_supplies	= ARRAY_SIZE(am335x_vdd2_supply),
    	.consumer_supplies	= am335x_vdd2_supply,
    	.ignore_check_consumers = 1,
    };
    
    static struct tps65910_board am335x_tps65910_info = {
    	.tps65910_pmic_init_data[TPS65910_REG_VRTC]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VIO]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VDD1]	= &am335x_vdd1,
    	.tps65910_pmic_init_data[TPS65910_REG_VDD2]	= &am335x_vdd2,
    	.tps65910_pmic_init_data[TPS65910_REG_VDD3]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VDIG1]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VDIG2]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VPLL]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VDAC]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VAUX1]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VAUX2]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VAUX33]	= &am335x_dummy,
    	.tps65910_pmic_init_data[TPS65910_REG_VMMC]	= &am335x_dummy,
    };
    
    /*
    * Daughter board Detection.
    * Every board has a ID memory (EEPROM) on board. We probe these devices at
    * machine init, starting from daughter board and ending with baseboard.
    * Assumptions :
    *	1. probe for i2c devices are called in the order they are included in
    *	   the below struct. Daughter boards eeprom are probed 1st. Baseboard
    *	   eeprom probe is called last.
    */
    static struct i2c_board_info __initdata am335x_i2c0_boardinfo[] = {
    	{
    		I2C_BOARD_INFO("tps65910", TPS65910_I2C_ID1),
    		.platform_data  = &am335x_tps65910_info,
    	},
    };
    
    static struct omap_musb_board_data musb_board_data = {
    	.interface_type	= MUSB_INTERFACE_ULPI,
    	/*
    	 * mode[0:3] = USB0PORT's mode
    	 * mode[4:7] = USB1PORT's mode
    	 * AM335X beta EVM has USB0 in OTG mode and USB1 in host mode.
    	 */
    	.mode           = (MUSB_HOST << 4) | MUSB_OTG,
    	.power		= 500,
    	.instances	= 1,
    };
    
    static void __init am335x_evm_i2c_init(void)
    {	
    	omap_register_i2c_bus(1, 100, am335x_i2c0_boardinfo,
    								ARRAY_SIZE(am335x_i2c0_boardinfo));	
    }
    
    void __iomem *am33xx_emif_base;
    
    void __iomem * __init am33xx_get_mem_ctlr(void)
    {
    
    	am33xx_emif_base = ioremap(AM33XX_EMIF0_BASE, SZ_32K);
    
    	if (!am33xx_emif_base)
    		pr_warning("%s: Unable to map DDR2 controller",	__func__);
    
    	return am33xx_emif_base;
    }
    
    void __iomem *am33xx_get_ram_base(void)
    {
    	return am33xx_emif_base;
    }
    
    void __iomem *am33xx_gpio0_base;
    
    void __iomem *am33xx_get_gpio0_base(void)
    {
    	am33xx_gpio0_base = ioremap(AM33XX_GPIO0_BASE, SZ_4K);
    
    	return am33xx_gpio0_base;
    }
    
    static struct resource am33xx_cpuidle_resources[] = {
    	{
    		.start		= AM33XX_EMIF0_BASE,
    		.end		= AM33XX_EMIF0_BASE + SZ_32K - 1,
    		.flags		= IORESOURCE_MEM,
    	},
    };
    
    /* AM33XX devices support DDR2 power down */
    static struct am33xx_cpuidle_config am33xx_cpuidle_pdata = {
    	.ddr2_pdown	= 1,
    };
    
    static struct platform_device am33xx_cpuidle_device = {
    	.name			= "cpuidle-am33xx",
    	.num_resources		= ARRAY_SIZE(am33xx_cpuidle_resources),
    	.resource		= am33xx_cpuidle_resources,
    	.dev = {
    		.platform_data	= &am33xx_cpuidle_pdata,
    	},
    };
    
    static void __init am33xx_cpuidle_init(void)
    {
    	int ret;
    
    	am33xx_cpuidle_pdata.emif_base = am33xx_get_mem_ctlr();
    
    	ret = platform_device_register(&am33xx_cpuidle_device);
    
    	if (ret)
    		pr_warning("AM33XX cpuidle registration failed\n");
    
    }
    
    static void __init am335x_evm_init(void)
    {
    	am33xx_cpuidle_init();
    	am33xx_mux_init(board_mux);
    	omap_serial_init();
    	am335x_rtc_init();
    	clkout2_enable();
    	am335x_evm_i2c_init();
    	am335x_evm_setup();
    	omap_sdrc_init(NULL, NULL);
    	usb_musb_init(&musb_board_data);
    	omap_board_config = am335x_evm_config;
    	omap_board_config_size = ARRAY_SIZE(am335x_evm_config);
    	/* Create an alias for icss clock */
    	if (clk_add_alias("pruss", NULL, "pruss_uart_gclk", NULL))
    		pr_warn("failed to create an alias: icss_uart_gclk --> pruss\n");
    	/* Create an alias for gfx/sgx clock */
    	if (clk_add_alias("sgx_ck", NULL, "gfx_fclk", NULL))
    		pr_warn("failed to create an alias: gfx_fclk --> sgx_ck\n");
    }
    
    static void __init am335x_evm_map_io(void)
    {
    	omap2_set_globals_am33xx();
    	omapam33xx_map_common_io();
    }
    
    MACHINE_START(AM335XEVM, "am335xevm")
    	/* Maintainer: Texas Instruments */
    	.atag_offset	= 0x100,
    	.map_io		= am335x_evm_map_io,
    	.init_early	= am33xx_init_early,
    	.init_irq	= ti81xx_init_irq,
    	.handle_irq     = omap3_intc_handle_irq,
    	.timer		= &omap3_am33xx_timer,
    	.init_machine	= am335x_evm_init,
    MACHINE_END
    
    MACHINE_START(AM335XIAEVM, "am335xiaevm")
    	/* Maintainer: Texas Instruments */
    	.atag_offset	= 0x100,
    	.map_io		= am335x_evm_map_io,
    	.init_irq	= ti81xx_init_irq,
    	.init_early	= am33xx_init_early,
    	.timer		= &omap3_am33xx_timer,
    	.init_machine	= am335x_evm_init,
    MACHINE_END
    

    Senthil

  • Hi Senthil,

    It is obvious from the log that the crash is happening at the ti_tscadc_probe function. Please put some debug prints inside this function in order to see what exactly is happening.

    Best regards,
    Miroslav

  • Hi Miroslav,

    I am Balaji working with Mr. Senthil. I tried to put debug messages. I identified that it stops working when it access the following parameter.

    drivers/mfd/ti_tscadc.c

    tsc_wires = pdata->tsc_init->wires;

    i put the following line before this line.

    printk(KERN_INFO "BALAJI wires : %d \n",pdata->tsc_init->wires);

    After that the kernel print the following print message.

    "Unable to handle kernel NULL pointer dereference at virtual addr0"

    Regards

    Balaji

  • Hi Miroslav

    Can you please tell us, is that ADC driver needs the following option in menuconfig.

    Device Drivers  --->

    Multifunction device drivers  --->  

    <*> TI ADC / Touch Screen chip support

    we have done the steps as per in TI ADC Driver guide.

    Regards

    Balaji

  • Hi Balaji,

    Yes, the TI ADC / Touch Screen chip support is needed. Here is the info from the Kconfig file:

    config MFD_TI_TSCADC
        tristate "TI ADC / Touch Screen chip support"
        help
          If you say yes here you get support for Texas Instruments series
          of Touch Screen /ADC chips.
          To compile this driver as a module, choose M here: the
          module will be called ti_tscadc.

    Did you disable it?

    Best regards,
    Miroslav

  • Hi Miroslav,

    I didnt disable it. The panic happen only because of that driver only. The MFD_TI_TSCADC driver access the wires in platform data but as per the ADC guide
    i removed the tsc_init from the board file. As for your reference Senthil attached the board file.

    If i unselect MFD_TI_TSCADC driver. The kernel loads normally.

    Regards

    Balaji

  • Hi Balaji,

    When you remove the MFD_TI_TSCADC config, you disable the support for the TI TSC/ADC chip, so neither the TSC, nor the ADC should work.

    Anyway, please try the following board file configuration:


    static struct tsc_data am335x_touchscreen_data  = {
        .wires  = 0,
        .x_plate_resistance = 200,
        .steps_to_configure = 5,
    };

    static struct adc_data am335x_adc_data = {
        .adc_channels = 8,
    };

    static struct mfd_tscadc_board tscadc = {
        .tsc_init = &am335x_touchscreen_data,
        .adc_init = &am335x_adc_data,
    };

    I'm simply setting the tsc_init.wires element to 0 rather than commenting out the whole structure. Otherwise this element of the structure is not initialized, so the kernel crashes when trying to dereference a pointer to it.

    When I do this, the kernel starts normally and then when I insmod the ti_adc.ko kernel module this is what I get:

    root@am335x-evm:/# ls -la /sys/bus/iio/devices/iio\:device0/
    drwxr-xr-x    3 root     root            0 Apr 11 12:57 .
    drwxr-xr-x    4 root     root            0 Jan  1  2000 ..
    -r--r--r--    1 root     root         4096 Apr 11 12:57 dev
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage0_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage1_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage2_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage3_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage4_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage5_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage6_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 in_voltage7_raw
    -r--r--r--    1 root     root         4096 Apr 11 12:57 name
    drwxr-xr-x    2 root     root            0 Apr 11 12:57 power
    lrwxrwxrwx    1 root     root            0 Apr 11 12:57 subsystem -> ../../../../../../bus/iio
    -rw-r--r--    1 root     root         4096 Apr 11 12:57 uevent

    Best regards,
    Miroslav

  • Thank you very much Miroslav. I can successfully read the battery charge level now. 

    Can you please help me on following thread

    http://e2e.ti.com/support/embedded/linux/f/354/t/252159.aspx 


    -Balaji

  • Hi Balaji,

    Your thread about the battery level indicator was moved to the Linux forums, because it is platform independent. This forum here is for specific issues about the AM335x Sitara ARM processors. The guys at the Linux forums will be more competent to answer you questions about the Matrix GUI.

    Best regards,
    Miroslav

  • even with git,  you can't follow all branches of arago project.

    don't you think a change log is needed, especially when the adc support code is compeletly rewritten.

  • Hi Miroslav,

    I meet this problem as you wrote. I use linux-3.2.0-psp05.06.00.00 , when I delete the whole am335x_touchscreen_data structure as AM335x ADC Driver's Guide - Texas Instruments Wiki says,  kernel crashes at booting. Does this becuase we use different kernel version?

    Best Regards

    xixiguo