static int config_s3c_wm8350_gpio(struct wm8350 *wm8350)
{
	wm8350_gpio_config(wm8350, 2, WM8350_GPIO_DIR_OUT,
			   WM8350_GPIO2_32KHZ_OUT, WM8350_GPIO_ACTIVE_LOW,
			   WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
			   WM8350_GPIO_DEBOUNCE_OFF);

	// cradle led
	wm8350_gpio_config(wm8350, 10, WM8350_GPIO_DIR_IN,
			   WM8350_GPIO10_GPIO_IN, WM8350_GPIO_ACTIVE_LOW,
			   WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
			   WM8350_GPIO_DEBOUNCE_OFF);

	wm8350_gpio_config(wm8350, 11, WM8350_GPIO_DIR_IN,
			   WM8350_GPIO11_GPIO_IN, WM8350_GPIO_ACTIVE_LOW,
			   WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
			   WM8350_GPIO_DEBOUNCE_OFF);

	// line sw
	wm8350_gpio_config(wm8350, 12, WM8350_GPIO_DIR_OUT,
			   WM8350_GPIO12_LINE_EN_OUT, WM8350_GPIO_ACTIVE_LOW,
			   WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
			   WM8350_GPIO_DEBOUNCE_ON);

	/* Chager LED initial */
	wm8350_gpio_set_status(wm8350, 10, 1);
	wm8350_gpio_set_status(wm8350, 11, 1);

	// avoid lcd backlight flicker
	if (q_hw_ver(KTQOOK_TP)) {
		wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_OUT,
				   WM8350_GPIO11_GPIO_OUT, WM8350_GPIO_ACTIVE_LOW,
				   WM8350_GPIO_PULL_NONE, WM8350_GPIO_INVERT_OFF,
				   WM8350_GPIO_DEBOUNCE_OFF);
		wm8350_gpio_set_status(wm8350, 4, 1);
	}

	return 0;
}
int wm8350_init(struct wm8350 *wm8350)
{
    int ret = 0;

    /* register regulator and set constraints */
    wm8350_device_register_pmic(wm8350);
    set_regulator_constraints(wm8350);
#ifdef NOT_PORTED_TO_IMX37
    wm8350_device_register_rtc(wm8350);
    wm8350_device_register_wdg(wm8350);
    wm8350_device_register_power(wm8350);
#endif
    mxc_init_wm8350();

    /*Note: Needs to be moved into a regulator function. */
    /* Configuring -- GPIO 7 pin */
    if (wm8350_gpio_config(wm8350, 7, WM8350_GPIO_DIR_OUT, 0,
                           WM8350_GPIO_ACTIVE_LOW, WM8350_GPIO_PULL_NONE,
                           WM8350_GPIO_INVERT_OFF,
                           WM8350_GPIO_DEBOUNCE_OFF) == 0)
        wm8350_gpio_set_status(wm8350, 7, 1);
    else
        printk(KERN_ERR "Error in setting Wolfson GPIO pin 7 \n");
    /* enable gpio4:USB_VBUS_EN */
    ret =
        wm8350_gpio_config(wm8350, 4, WM8350_GPIO_DIR_IN,
                           WM8350_GPIO4_MR_IN, WM8350_GPIO_ACTIVE_HIGH,
                           WM8350_GPIO_PULL_UP, WM8350_GPIO_INVERT_OFF,
                           WM8350_GPIO_DEBOUNCE_OFF);
    if (ret)
        printk(KERN_ERR "Error in setting USB VBUS enable pin\n");

    /*PMIC RDY*/
    if (wm8350_gpio_config(wm8350, 9, WM8350_GPIO_DIR_OUT, WM8350_GPIO9_GPIO_OUT,
                           WM8350_GPIO_ACTIVE_LOW, WM8350_GPIO_PULL_NONE,
                           WM8350_GPIO_INVERT_OFF, WM8350_GPIO_DEBOUNCE_OFF) == 0)
        wm8350_gpio_set_status(wm8350, 9, 1);
    else
        printk(KERN_ERR "Error in setting Wolfson GPIO pin 9 \n");

    /* register sound */
    printk("Registering imx37_snd_device");
    imx_snd_device = platform_device_alloc("wm8350-imx-3stack-audio", -1);
    if (!imx_snd_device) {
        ret = -ENOMEM;
        goto err;
    }
    imx_snd_device->dev.platform_data = &imx_3stack_audio_platform_data;
    platform_set_drvdata(imx_snd_device, &wm8350->audio);
    ret = platform_device_add(imx_snd_device);
    if (ret)
        goto snd_err;

    /* set up PMIC IRQ (active high) to i.MX32ADS */
    printk("Registering PMIC INT");
    INIT_WORK(&wm8350->work, wm8350_irq_work);
    wm8350_reg_unlock(wm8350);
    wm8350_set_bits(wm8350, WM8350_SYSTEM_CONTROL_1, WM8350_IRQ_POL);
    wm8350_reg_lock(wm8350);
    set_irq_type(MXC_PMIC_INT_LINE, IRQT_RISING);
    ret = request_irq(MXC_PMIC_INT_LINE, wm8350_irq_handler,
                      IRQF_DISABLED, "wm8350-pmic", wm8350);
    if (ret != 0) {
        printk(KERN_ERR "wm8350: cant request irq %d\n",
               MXC_PMIC_INT_LINE);
        goto err;
    }
    wm8350->nirq = MXC_PMIC_INT_LINE;

    set_irq_wake(MXC_PMIC_INT_LINE, 1);

#ifdef NOT_PORTED_TO_IMX37
    printk("Configuring WM8350 GPIOS");
    config_gpios(wm8350);
    config_hibernate(wm8350);
#endif

    /* Sw1 --> PWR_ON */
    printk("Registering and unmasking the WM8350 wakeup key\n");
    wm8350_register_irq(wm8350, WM8350_IRQ_WKUP_ONKEY,
                        imx37_3stack_switch_handler, NULL);
    wm8350_unmask_irq(wm8350, WM8350_IRQ_WKUP_ONKEY);

    /* unmask all & clear sticky */
    printk("Unmasking WM8350 local interrupts\n");
    wm8350_reg_write(wm8350, WM8350_SYSTEM_INTERRUPTS_MASK, 0x3ffe);
    schedule_work(&wm8350->work);

#if BATTERY
    /* not much use without a battery atm */
    wm8350_init_battery(wm8350);
#endif

    printk("Exiting normally from wm8350_init()");
    return ret;
snd_err:
    platform_device_put(imx_snd_device);

err:
    printk("wm8350_init() FAILED");
    kfree(wm8350->reg_cache);
    return ret;
}