Exemplo n.º 1
0
/*
 * 	udc_disable - disable USB device controller
 */
static void udc_disable(struct s3c_udc *dev)
{
	DEBUG_SETUP("%s: %p\n", __FUNCTION__, dev);

	udc_set_address(dev, 0);

	dev->ep0state = WAIT_FOR_SETUP;
	dev->gadget.speed = USB_SPEED_UNKNOWN;
	dev->usb_address = 0;

	/* usb power disable */
#if defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
	s3c2410_gpio_pullup(S3C2443_GPH14, 1); /* pull-down enable */
	s3c2410_gpio_pullup(S3C2410_GPF2, 1);  /* pull-down enable */
#else
	s3c2410_gpio_pullup(S3C2443_GPH14, 2); /* pull-down enable */
#endif
	s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
	s3c2410_gpio_setpin(S3C2443_GPH14, 0);

	/* usb clock disable */
	__raw_writel(0, S3C_UCLKCON);

	/* USB Port is Suspend mode */
	__raw_writel(__raw_readl(S3C2410_MISCCR)|(1<<12), S3C2410_MISCCR);

	/* PHY power disable */
	__raw_writel(__raw_readl(S3C_PWRCFG)&~(1<<4), S3C_PWRCFG);

}
Exemplo n.º 2
0
void gta02_lis302dl_suspend_io(struct lis302dl_info *lis, int resume)
{
	struct lis302dl_platform_data *pdata = lis->pdata;

	if (!resume) {
		 /*
		 * we don't want to power them with a high level
		 * because GSENSOR_3V3 is not up during suspend
		 */
		s3c2410_gpio_setpin(pdata->pin_chip_select, 0);
		s3c2410_gpio_setpin(pdata->pin_clk, 0);
		s3c2410_gpio_setpin(pdata->pin_mosi, 0);
		/* misnomer: it is a pullDOWN in 2442 */
		s3c2410_gpio_pullup(pdata->pin_miso, 1);
		return;
	}

	/* back to normal */
	s3c2410_gpio_setpin(pdata->pin_chip_select, 1);
	s3c2410_gpio_setpin(pdata->pin_clk, 1);
	/* misnomer: it is a pullDOWN in 2442 */
	s3c2410_gpio_pullup(pdata->pin_miso, 0);

	s3c2410_gpio_cfgpin(pdata->pin_chip_select, S3C2410_GPIO_OUTPUT);
	s3c2410_gpio_cfgpin(pdata->pin_clk, S3C2410_GPIO_OUTPUT);
	s3c2410_gpio_cfgpin(pdata->pin_mosi, S3C2410_GPIO_OUTPUT);
	s3c2410_gpio_cfgpin(pdata->pin_miso, S3C2410_GPIO_INPUT);

}
Exemplo n.º 3
0
static inline void s3cfb_spi_set_lcd_data(int ch)
{
	s3c2410_gpio_cfgpin(S3C_FB_SPI_CLK(ch), 1);
	s3c2410_gpio_cfgpin(S3C_FB_SPI_MOSI(ch), 1);
	s3c2410_gpio_cfgpin(S3C_FB_SPI_CS(ch), 1);

	s3c2410_gpio_pullup(S3C_FB_SPI_CLK(ch), 2);
	s3c2410_gpio_pullup(S3C_FB_SPI_MOSI(ch), 2);
	s3c2410_gpio_pullup(S3C_FB_SPI_CS(ch), 2);
}
Exemplo n.º 4
0
static int s3c24xx_serial_startup(struct uart_port *port)
{
	struct s3c24xx_uart_port *ourport = to_ourport(port);
	int ret;

	dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
	    port->mapbase, port->membase);

        if (port->line == 2) {
       	    s3c2410_gpio_cfgpin(S3C2410_GPH6, S3C2410_GPH6_TXD2);
    	    s3c2410_gpio_pullup(S3C2410_GPH6, 1); 

    	    s3c2410_gpio_cfgpin(S3C2410_GPH7, S3C2410_GPH7_RXD2);
    	    s3c2410_gpio_pullup(S3C2410_GPH7, 1); 
        }

	rx_enabled(port) = 1;

	ret = request_irq(RX_IRQ(port),
			  s3c24xx_serial_rx_chars, 0,
			  s3c24xx_serial_portname(port), ourport);

	if (ret != 0) {
		printk(KERN_ERR "cannot get irq %d\n", RX_IRQ(port));
		return ret;
	}

	ourport->rx_claimed = 1;

	dbg("requesting tx irq...\n");

	tx_enabled(port) = 1;

	ret = request_irq(TX_IRQ(port),
			  s3c24xx_serial_tx_chars, 0,
			  s3c24xx_serial_portname(port), ourport);

	if (ret) {
		printk(KERN_ERR "cannot get irq %d\n", TX_IRQ(port));
		goto err;
	}

	ourport->tx_claimed = 1;

	dbg("s3c24xx_serial_startup ok\n");

	/* the port reset code should have done the correct
	 * register setup for the port controls */

	return ret;

 err:
	s3c24xx_serial_shutdown(port);
	return ret;
}
Exemplo n.º 5
0
static void
_get_lcd_panel_id(void)
{
	// set gpio in for lcd panel id
	s3c2410_gpio_cfgpin(S3C2410_GPD8, S3C2410_GPD8_INP);
	s3c2410_gpio_cfgpin(S3C2410_GPD9, S3C2410_GPD9_INP);
	s3c2410_gpio_cfgpin(S3C2410_GPD10, S3C2410_GPD10_INP);

	// set pull up/down disable for lcd panel id
	s3c2410_gpio_pullup(S3C2410_GPD8, 0);
	s3c2410_gpio_pullup(S3C2410_GPD9, 0);
	s3c2410_gpio_pullup(S3C2410_GPD10, 0);

	_lcd_panel_id = (__raw_readl(S3C2410_GPDDAT) & 0x700) >> 8;
	printk(KERN_INFO "CANOPUS LCD Panel ID [0x%x]\n", _lcd_panel_id);
}
Exemplo n.º 6
0
void __init bit2440_init(void)
{
	set_s3c2410ts_info(&bit2440_ts_cfg);
	set_s3c2410udc_info(&bit2440_udc_cfg);
	set_s3c2410fb_info(&bit2440_lcdcfg); 
	
	s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_OUTP);
	s3c2410_gpio_pullup(S3C2410_GPH0, 0); 
	s3c2410_gpio_setpin(S3C2410_GPH0, 0); 
	/*	set LED start status by lili */
	s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_OUTP);
	s3c2410_gpio_cfgpin(S3C2410_GPF5, S3C2410_GPF5_OUTP);
	s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_OUTP);
	s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_OUTP);

	s3c2410_gpio_setpin(S3C2410_GPF4, 0);
	s3c2410_gpio_setpin(S3C2410_GPF5, 0);
	s3c2410_gpio_setpin(S3C2410_GPF6, 0);
	s3c2410_gpio_setpin(S3C2410_GPF7, 0);

	/* Add by lili for usb setup*/
	printk("USB Power Control, (c) 2004 Simtec Electronics\n");
	s3c_device_usb.dev.platform_data = &usb_simtec_info;

	s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
	s3c2410_gpio_setpin(S3C2410_GPB4, 1);

}
Exemplo n.º 7
0
void s3c24xx_spi_gpiocfg_bus0_gpe11_12_13(struct s3c2410_spi_info *spi,
					  int enable)
{
	if (enable) {
		s3c2410_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPE13_SPICLK0);
		s3c2410_gpio_cfgpin(S3C2410_GPE(12), S3C2410_GPE12_SPIMOSI0);
		s3c2410_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPE11_SPIMISO0);
		s3c2410_gpio_pullup(S3C2410_GPE(11), 0);
		s3c2410_gpio_pullup(S3C2410_GPE(13), 0);
	} else {
		s3c2410_gpio_cfgpin(S3C2410_GPE(13), S3C2410_GPIO_INPUT);
		s3c2410_gpio_cfgpin(S3C2410_GPE(11), S3C2410_GPIO_INPUT);
		s3c2410_gpio_pullup(S3C2410_GPE(11), 1);
		s3c2410_gpio_pullup(S3C2410_GPE(12), 1);
		s3c2410_gpio_pullup(S3C2410_GPE(13), 1);
	}
}
Exemplo n.º 8
0
static void l3_setdir(void *data, int in)
{
	struct bit_data *bits = data;
	unsigned long flags;

	local_irq_save(flags);
	if (in)
	{
		s3c2410_gpio_cfgpin( (bits->sda), S3C2410_GPB3_INP);
    	s3c2410_gpio_pullup( (bits->sda), 1); 
	}
	else
	{
		s3c2410_gpio_cfgpin( (bits->sda), S3C2410_GPB3_OUTP);
    	s3c2410_gpio_pullup( (bits->sda), 1); 
	}
	local_irq_restore(flags);
}
Exemplo n.º 9
0
int gta02_get_pcb_revision(void)
{
	int n;
	int u = 0;
	static unsigned long pinlist[] = {
		GTA02_PCB_ID1_0,
		GTA02_PCB_ID1_1,
		GTA02_PCB_ID1_2,
		GTA02_PCB_ID2_0,
		GTA02_PCB_ID2_1,
	};
	static int pin_offset[] = {
		0, 1, 2, 8, 9
	};

	for (n = 0 ; n < ARRAY_SIZE(pinlist); n++) {
		/*
		 * set the PCB version GPIO to be pulled-down input
		 * force low briefly first
		 */
		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
		s3c2410_gpio_setpin(pinlist[n], 0);
		/* misnomer: it is a pullDOWN in 2442 */
		s3c2410_gpio_pullup(pinlist[n], 1);
		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_INPUT);

		udelay(10);

		if (s3c2410_gpio_getpin(pinlist[n]))
			u |= 1 << pin_offset[n];

		/*
		* when not being interrogated, all of the revision GPIO
		* are set to output HIGH without pulldown so no current flows
		* if they are NC or pulled up.
		*/
		s3c2410_gpio_setpin(pinlist[n], 1);
		s3c2410_gpio_cfgpin(pinlist[n], S3C2410_GPIO_OUTPUT);
		/* misnomer: it is a pullDOWN in 2442 */
		s3c2410_gpio_pullup(pinlist[n], 0);
	}

	return u;
}
Exemplo n.º 10
0
static int h1940_backlight_init(struct device *dev)
{
	gpio_request(S3C2410_GPB(0), "Backlight");

	s3c2410_gpio_setpin(S3C2410_GPB(0), 0);
	s3c2410_gpio_pullup(S3C2410_GPB(0), 0);
	s3c2410_gpio_cfgpin(S3C2410_GPB(0), S3C2410_GPB0_TOUT0);

	return 0;
}
Exemplo n.º 11
0
void s3c24xx_spi_gpiocfg_bus1_gpd8_9_10(struct s3c2410_spi_info *spi,
					int enable)
{

	printk(KERN_INFO "%s(%d)\n", __func__, enable);
	if (enable) {
		s3c2410_gpio_cfgpin(S3C2410_GPD(10), S3C2440_GPD10_SPICLK1);
		s3c2410_gpio_cfgpin(S3C2410_GPD(9), S3C2440_GPD9_SPIMOSI1);
		s3c2410_gpio_cfgpin(S3C2410_GPD(8), S3C2440_GPD8_SPIMISO1);
		s3c2410_gpio_pullup(S3C2410_GPD(10), 0);
		s3c2410_gpio_pullup(S3C2410_GPD(9), 0);
	} else {
		s3c2410_gpio_cfgpin(S3C2410_GPD(8), S3C2410_GPIO_INPUT);
		s3c2410_gpio_cfgpin(S3C2410_GPD(9), S3C2410_GPIO_INPUT);
		s3c2410_gpio_pullup(S3C2410_GPD(10), 1);
		s3c2410_gpio_pullup(S3C2410_GPD(9), 1);
		s3c2410_gpio_pullup(S3C2410_GPD(8), 1);
	}
}
Exemplo n.º 12
0
static int __init h1940bt_probe(struct platform_device *pdev)
{
    /* Configures BT serial port GPIOs */
    s3c2410_gpio_cfgpin(S3C2410_GPH0, S3C2410_GPH0_nCTS0);
    s3c2410_gpio_pullup(S3C2410_GPH0, 1);
    s3c2410_gpio_cfgpin(S3C2410_GPH1, S3C2410_GPH1_OUTP);
    s3c2410_gpio_pullup(S3C2410_GPH1, 1);
    s3c2410_gpio_cfgpin(S3C2410_GPH2, S3C2410_GPH2_TXD0);
    s3c2410_gpio_pullup(S3C2410_GPH2, 1);
    s3c2410_gpio_cfgpin(S3C2410_GPH3, S3C2410_GPH3_RXD0);
    s3c2410_gpio_pullup(S3C2410_GPH3, 1);

#ifdef CONFIG_LEDS_H1940
    led_trigger_register_simple("h1940-bluetooth", &bt_led_trigger);
#endif

    /* disable BT by default */
    h1940bt_enable(0);

    return device_create_file(&pdev->dev, &dev_attr_enable);
}
Exemplo n.º 13
0
static void _get_hw_version(void)
{
	_hw_version = 0;

	// set version bit to input pullup
	s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_INP);
	s3c2410_gpio_pullup(S3C2410_GPE7, 2);

	s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_INP);
	s3c2410_gpio_pullup(S3C2410_GPE8, 2);

	s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_INP);
	s3c2410_gpio_pullup(S3C2410_GPE9, 2);

	s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE9_INP);
	s3c2410_gpio_pullup(S3C2410_GPE10, 2);

	s3c2410_gpio_cfgpin(S3C2410_GPH6, S3C2410_GPH6_INP);
	s3c2410_gpio_pullup(S3C2410_GPH6, 2);

	_hw_version += (s3c2410_gpio_getpin(S3C2410_GPE7) ? 1 << 0 : 0);
	_hw_version += (s3c2410_gpio_getpin(S3C2410_GPE8) ? 1 << 1 : 0);
	_hw_version += (s3c2410_gpio_getpin(S3C2410_GPE9) ? 1 << 2 : 0);
	_hw_version += (s3c2410_gpio_getpin(S3C2410_GPE10) ? 1 << 3 : 0);
	_hw_version += (s3c2410_gpio_getpin(S3C2410_GPH6) ? 1 << 4 : 0);

	// set version bit to disable pullup
	s3c2410_gpio_pullup(S3C2410_GPE7, 0);
	s3c2410_gpio_pullup(S3C2410_GPE8, 0);
	s3c2410_gpio_pullup(S3C2410_GPE9, 0);
	s3c2410_gpio_pullup(S3C2410_GPE10, 0);
	s3c2410_gpio_pullup(S3C2410_GPH6, 0);

	printk(KERN_INFO "CANOPUS H/W ver. 0x%x\n", _hw_version);

	/* proc */
	_proc_dir = create_proc_entry("hwversion", 0, NULL);
	_proc_dir->read_proc = (read_proc_t *)_proc_hw_version;
	_proc_dir->data = NULL;
}
Exemplo n.º 14
0
static int __devinit h1940bt_probe(struct platform_device *pdev)
{
	struct rfkill *rfk;
	int ret = 0;

	/* Configures BT serial port GPIOs */
	s3c2410_gpio_cfgpin(S3C2410_GPH(0), S3C2410_GPH0_nCTS0);
	s3c2410_gpio_pullup(S3C2410_GPH(0), 1);
	s3c2410_gpio_cfgpin(S3C2410_GPH(1), S3C2410_GPIO_OUTPUT);
	s3c2410_gpio_pullup(S3C2410_GPH(1), 1);
	s3c2410_gpio_cfgpin(S3C2410_GPH(2), S3C2410_GPH2_TXD0);
	s3c2410_gpio_pullup(S3C2410_GPH(2), 1);
	s3c2410_gpio_cfgpin(S3C2410_GPH(3), S3C2410_GPH3_RXD0);
	s3c2410_gpio_pullup(S3C2410_GPH(3), 1);


	rfk = rfkill_alloc(DRV_NAME, &pdev->dev, RFKILL_TYPE_BLUETOOTH,
			&h1940bt_rfkill_ops, NULL);
	if (!rfk) {
		ret = -ENOMEM;
		goto err_rfk_alloc;
	}

	rfkill_set_led_trigger_name(rfk, "h1940-bluetooth");

	ret = rfkill_register(rfk);
	if (ret)
		goto err_rfkill;

	platform_set_drvdata(pdev, rfk);

	return 0;

err_rfkill:
	rfkill_destroy(rfk);
err_rfk_alloc:
	return ret;
}
Exemplo n.º 15
0
static int usb20_phy_init(void)
{
	s3c2410_gpio_pullup(S3C2443_GPH14, 2); /* usb power pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPF2, 0);  /* vbus detect pull-up/down disable */
	s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
	s3c2410_gpio_setpin(S3C2443_GPH14, 1); 	/* usb power enbale */

	mdelay(1);

	/* if reset by sleep wakeup, control the retention I/O cell */
	if (readl(S3C_RSTSTAT) & 0x8)
		writel(readl(S3C_RSTCON)|(1<<16), S3C_RSTCON);


	/* USB Port is Normal mode */
	writel(readl(S3C2410_MISCCR)&~(1<<12), S3C2410_MISCCR);

	/* PHY power enable */
	writel(readl(S3C_PWRCFG)|(1<<4), S3C_PWRCFG);

	/* USB device 2.0 must reset like bellow,
	 * 1st phy reset and after at least 10us, func_reset & host reset
	 * phy reset can reset bellow registers.
	 */
	/* PHY 2.0 S/W reset */
	writel((0<<2)|(0<<1)|(1<<0), S3C_URSTCON);
	udelay(20); /* phy reset must be asserted for at 10us */

	/*Function 2.0, Host 1.1 S/W reset*/
	writel((1<<2)|(1<<1)|(0<<0), S3C_URSTCON);
	writel((0<<2)|(0<<1)|(0<<0), S3C_URSTCON);

	writel(0x00000030, S3C2443_CLKREG(0x84));
	writel(0x80000005, S3C2443_CLKREG(0x8c));
	writel(5, S3C2443_CLKREG(0x80));

	return 0;
}
Exemplo n.º 16
0
static void amlm5900_init_pm(void)
{
	int ret = 0;

	ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt,
				IRQF_TRIGGER_RISING | IRQF_SHARED,
				"amlm5900_wakeup", &amlm5900_wake_interrupt);
	if (ret != 0) {
		printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret);
	} else {
		enable_irq_wake(IRQ_EINT9);
		/* configure the suspend/resume status pin */
		s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP);
		s3c2410_gpio_pullup(S3C2410_GPF2, 0);
	}
}
Exemplo n.º 17
0
static int s3c24xx_led_probe(struct platform_device *dev)
{
	struct s3c24xx_led_platdata *pdata = dev->dev.platform_data;
	struct s3c24xx_gpio_led *led;
	int ret;

	led = kzalloc(sizeof(struct s3c24xx_gpio_led), GFP_KERNEL);
	if (led == NULL) {
		dev_err(&dev->dev, "No memory for device\n");
		return -ENOMEM;
	}

	platform_set_drvdata(dev, led);

	led->cdev.brightness_set = s3c24xx_led_set;
	led->cdev.default_trigger = pdata->def_trigger;
	led->cdev.name = pdata->name;
	led->cdev.flags |= LED_CORE_SUSPENDRESUME;

	led->pdata = pdata;

	/* no point in having a pull-up if we are always driving */

	if (pdata->flags & S3C24XX_LEDF_TRISTATE) {
		s3c2410_gpio_setpin(pdata->gpio, 0);
		s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_INPUT);
	} else {
		s3c2410_gpio_pullup(pdata->gpio, 0);
		s3c2410_gpio_setpin(pdata->gpio, 0);
		s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_OUTPUT);
	}

	/* register our new led device */

	ret = led_classdev_register(&dev->dev, &led->cdev);
	if (ret < 0) {
		dev_err(&dev->dev, "led_classdev_register failed\n");
		goto exit_err1;
	}

	return 0;

 exit_err1:
	kfree(led);
	return ret;
}
Exemplo n.º 18
0
static int tq2440_led_probe(struct platform_device *dev)
{
	int ret = 0;
	struct tq2440_leds *leds = NULL;
	struct s3c24xx_led_platdata *pdata = dev->dev.platform_data;
	
//	if (!(leds = kmalloc(sizeof(*leds), GFP_KERNEL))) 
	if (!(leds = kzalloc(sizeof(*leds), GFP_KERNEL))) 	// the memroy should set to 0!!!!!!!!
		printk(KERN_ERR "%s: no memory\n", __func__);

	printk(KERN_INFO "%s: tq2440_leds addr: %p\n", __func__, leds);
	platform_set_drvdata(dev, leds);
	leds->leddev.name 		= pdata->name;
	leds->leddev.brightness_set 	= tq2440_leds_set;
	leds->leddev.brightness_get	= tq2440_leds_get;
//	leds->leddev.flags		|= LED_CORE_SUSPENDRESUME;
	leds->pdata 			= pdata;
//	leds->leddev.default_trigger	= pdata->def_trigger;

	printk(KERN_INFO "%s: requesting leds gpio: %d\n", __func__, pdata->gpio);
	if ((ret = gpio_request(pdata->gpio, "tq2440 leds")) < 0) {
		printk(KERN_ERR "requesting leds gpio: %d failed\n", pdata->gpio);
		goto out;
	}

	s3c2410_gpio_pullup(pdata->gpio, 0);
	s3c2410_gpio_setpin(pdata->gpio, 0);	// set the gpio to zero
	s3c2410_gpio_cfgpin(pdata->gpio, S3C2410_GPIO_OUTPUT);

	ret = led_classdev_register(&dev->dev, &leds->leddev);
	if (ret < 0) {
		printk(KERN_ERR "%s: can register led class device\n", __func__);
		goto out2;
	}
	printk(KERN_INFO "%s: register OK\n", __func__);

out2:
	gpio_free(pdata->gpio);
out:
	kfree(leds);
	return ret;
}
Exemplo n.º 19
0
void canopus_gpio_init(void)
{
	printk("canopus_gpio_init\n");

	_get_hw_version();
	_get_lcd_panel_id();

	// Speaker AMP
	s3c2410_gpio_cfgpin(S3C2410_GPH8, S3C2410_GPH8_OUTP);
	s3c2410_gpio_setpin(S3C2410_GPH8, 0);

	// key LED
	s3c2410_gpio_cfgpin(S3C2410_GPD15, S3C2410_GPD15_OUTP);
	s3c2410_gpio_setpin(S3C2410_GPD15, 0);

	// moter
	s3c2410_gpio_cfgpin(S3C2410_GPH5, S3C2410_GPH5_OUTP);
	s3c2410_gpio_setpin(S3C2410_GPH5, 0);

   	 // Wi-Fi
	wifi_gpio_init();

	// KeyPAD 	
	Key_gpio_init();

	if (q_hw_ver(KTQOOK)) {
		// phone direction
		s3c2410_gpio_pullup(S3C2410_GPE6, 0);
		s3c2410_gpio_setpin(S3C2410_GPE6, 0);
		s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2410_GPE6_INP);
	}

	// set clockout0 for usb
	if (q_hw_ver(SWP2000)
			|| q_hw_ver(7800_MP2)) {
		s3c2410_gpio_cfgpin(S3C2443_GPH13, S3C2443_GPH13_CLKOUT0);
	} else if (q_hw_ver(KTQOOK_TP2)
			|| q_hw_ver(KTQOOK_MP)
			|| q_hw_ver(SKATM)) {
		s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_CLKOUT1);
	}
}
Exemplo n.º 20
0
/*
 * iPAQs need the clock line driven hard high and low.
 */
static void l3_setscl(void *data, int state)
{
	struct bit_data *bits = data;
	unsigned long flags;

	local_irq_save(flags);
	if (state)
	{
		s3c2410_gpio_setpin(bits->scl, 1);
	}
	else
	{
		s3c2410_gpio_setpin(bits->scl, 0);
	}
		
	s3c2410_gpio_cfgpin( (bits->scl), S3C2410_GPB4_OUTP);
	s3c2410_gpio_pullup( (bits->scl), 1); 
	
	
	local_irq_restore(flags);
}
Exemplo n.º 21
0
void Key_gpio_init(void)
{
	u32 mask, mask1, mask2;

	mask  = __raw_readl(S3C2410_INTMSK);
	mask1 = __raw_readl(S3C2410_EXTINT0) & ~(0x00000007);
	mask2 = __raw_readl(S3C2410_EXTINT1) & ~(0x00777777);
	
	__raw_writel(mask1 | 0x00000002, S3C2410_EXTINT0);
	__raw_writel(mask2 | 0x00222222, S3C2410_EXTINT1);

	__raw_writel(mask | 0x21, S3C2410_INTMSK);
	__raw_writel(0x21, S3C2410_SRCPND);
	__raw_writel(0x21, S3C2410_INTPND);

	s3c2410_gpio_cfgpin(S3C2410_GPD11, S3C2410_GPD11_OUTP);
	s3c2410_gpio_cfgpin(S3C2410_GPD12, S3C2410_GPD12_OUTP);
	s3c2410_gpio_cfgpin(S3C2410_GPD13, S3C2410_GPD13_OUTP);	
	s3c2410_gpio_cfgpin(S3C2410_GPD14, S3C2410_GPD14_OUTP);

	s3c2410_gpio_setpin(S3C2410_GPD11, 0);
	s3c2410_gpio_setpin(S3C2410_GPD12, 0);
	s3c2410_gpio_setpin(S3C2410_GPD13, 0);
	s3c2410_gpio_setpin(S3C2410_GPD14, 0);	

	s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_EINT0);
	s3c2410_gpio_cfgpin(S3C2410_GPG0, S3C2410_GPG0_EINT8);
	s3c2410_gpio_cfgpin(S3C2410_GPG1, S3C2410_GPG1_EINT9);
	s3c2410_gpio_cfgpin(S3C2410_GPG2, S3C2410_GPG2_EINT10);	
	s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_EINT11);
	s3c2410_gpio_cfgpin(S3C2410_GPG4, S3C2410_GPG4_EINT12);	
	s3c2410_gpio_cfgpin(S3C2410_GPG5, S3C2410_GPG5_EINT13);	

	s3c2410_gpio_pullup(S3C2410_GPF0, 0);
	s3c2410_gpio_pullup(S3C2410_GPG0, 2);
	s3c2410_gpio_pullup(S3C2410_GPG1, 2);
	s3c2410_gpio_pullup(S3C2410_GPG2, 2);
	s3c2410_gpio_pullup(S3C2410_GPG3, 2);
	s3c2410_gpio_pullup(S3C2410_GPG4, 2);
	s3c2410_gpio_pullup(S3C2410_GPG5, 2);

	mdelay(100);
}
Exemplo n.º 22
0
void wifi_gpio_init (void)
{	
	unsigned long mask;

	// wifi reset
	s3c2410_gpio_setpin(S3C2410_GPF6, 1);	
	s3c2410_gpio_cfgpin(S3C2410_GPF6, S3C2410_GPF6_OUTP);

	// wifi power down
	s3c2410_gpio_setpin(S3C2410_GPF7, 1);
	s3c2410_gpio_cfgpin(S3C2410_GPF7, S3C2410_GPF7_OUTP);

	s3c2410_gpio_cfgpin(S3C2410_GPL0, S3C2410_GPL0_SD0_DAT0);
	s3c2410_gpio_cfgpin(S3C2410_GPL1, S3C2410_GPL1_SD0_DAT1);
	s3c2410_gpio_cfgpin(S3C2410_GPL2, S3C2410_GPL2_SD0_DAT02);
	s3c2410_gpio_cfgpin(S3C2410_GPL3, S3C2410_GPL3_SD0_DAT3);

	s3c2410_gpio_cfgpin(S3C2410_GPL8, S3C2410_GPL8_SD0_CMD);
	s3c2410_gpio_cfgpin(S3C2410_GPL9, S3C2410_GPL9_SD0_CLK);


	s3c2410_gpio_pullup(S3C2410_GPL0, 2); /* SD DAT0 pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPL1, 2); /* SD DAT1 pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPL2, 2); /* SD DAT2 pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPL3, 2); /* SD DAT3 pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPL8, 2); /* SD CMD pull-up enable */

	// set EXTINT4 for WOW
	s3c2410_gpio_cfgpin(S3C2410_GPF4, S3C2410_GPF4_EINT4);
	s3c2410_gpio_pullup(S3C2410_GPF4, 0);

	// set rising edge triggered
	mask = __raw_readl(S3C2410_EXTINT0) & ~(0x7<<16);
	__raw_writel(mask | (0x4 << 16) , S3C2410_EXTINT0);

	gpio_wifi_power(0); 
}
Exemplo n.º 23
0
int IO_irq_open(struct inode *inode, struct file *filp)
{
	struct IO_irq_dev *dev; /* device information */
	int result1,result2,result3,result4;

	spin_lock(&IO_irq_lock);

	while (! atomic_dec_and_test (&IO_irq_available)) {
		atomic_inc(&IO_irq_available);
		spin_unlock(&IO_irq_lock);
		if (filp->f_flags & O_NONBLOCK) return -EAGAIN;
		if (wait_event_interruptible (IO_irq_wait, atomic_read (&IO_irq_available)))
			return -ERESTARTSYS; /* tell the fs layer to handle it */
		
		spin_lock(&IO_irq_lock);
	}

	spin_unlock(&IO_irq_lock);

	dev = container_of(inode->i_cdev, struct IO_irq_dev, cdev);

	if ((dev->IO_irq1 >= IRQ_EINT0)&&(dev->IO_irq2 >= IRQ_EINT0)&&(dev->IO_irq3 >= IRQ_EINT0)&&(dev->IO_irq4 >= IRQ_EINT0))
	{
		result1 = request_irq(dev->IO_irq1, IO_irq_interrupt1, 0 , "IO_irq1", (void *)NULL);
		result2 = request_irq(dev->IO_irq2, IO_irq_interrupt2, 0 , "IO_irq2", (void *)NULL);
		result3 = request_irq(dev->IO_irq3, IO_irq_interrupt3, 0 , "IO_irq3", (void *)NULL);
		result4 = request_irq(dev->IO_irq4, IO_irq_interrupt4, 0 , "IO_irq4", (void *)NULL);
		if (result1 || result2 || result3 || result4 ) {
			printk( "IO_irq: can't get assigned one of irq \n");
			if (!result1) free_irq(IO_irq_devices->IO_irq1, NULL);
			if (!result2) free_irq(IO_irq_devices->IO_irq2, NULL);
			if (!result3) free_irq(IO_irq_devices->IO_irq3, NULL);
			if (!result4) free_irq(IO_irq_devices->IO_irq4, NULL);
			return -EAGAIN;
		} else { 
			s3c2410_gpio_cfgpin(S3C2410_GPG11, S3C2410_GPG11_EINT19);
			s3c2410_gpio_pullup(S3C2410_GPG11, 0);
			s3c2410_gpio_cfgpin(S3C2410_GPG3, S3C2410_GPG3_EINT11);
			s3c2410_gpio_pullup(S3C2410_GPG3, 0);
			s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_EINT2);
			s3c2410_gpio_pullup(S3C2410_GPF2, 0);
			s3c2410_gpio_cfgpin(S3C2410_GPF0, S3C2410_GPF0_EINT0);
			s3c2410_gpio_pullup(S3C2410_GPF0, 0);
			dev->IO_status = 0x1f ;
		}
	}
	else   {
		printk("IO_irq: get IRQ failed !\n");
		return -EAGAIN;
		}

	filp->private_data = dev; /* for other methods */

	tasklet_init(&keytask , key1_tasklet , (unsigned long)&key1);

	tekkamanwork = create_workqueue("tekkamanwork");
	INIT_DELAYED_WORK(&irq_work_delay, irq_work_delay_fn); 

	INIT_WORK(&irq_work, irq_work_fn);

	tekkamantmp = kmalloc(512, GFP_KERNEL);
	tekkamanbuf = kmalloc (512 , GFP_KERNEL);
	tekkamanfifo = kfifo_alloc(512, GFP_KERNEL, &tekkamanlock);
	
	printk( "IO_irq: opened !  \n");
	return nonseekable_open(inode, filp);          /* success */
}
Exemplo n.º 24
0
static int __init bus_init(void)
{
	struct bit_data *bit = &bit_data;
	unsigned long flags;
	int ret;

#if defined( CONFIG_ARCH_BIT2440) || defined (CONFIG_BOARD_S3C2440_SMDK)

dprintk("l3_2440 0\n");

	bit->sda     = S3C2410_GPB3;
	bit->scl     = S3C2410_GPB4;
	bit->l3_mode = S3C2410_GPB2;
#endif

	if (!bit->sda)
		return -ENODEV;

	/*
	 * Default level for L3 mode is low.
	 */

	local_irq_save(flags);

	/* L3 gpio interface set */
dprintk("l3_2440 1\n");	
    s3c2410_gpio_setpin(bit->l3_mode, 1); 
	s3c2410_gpio_setpin(bit->scl, 1);

	s3c2410_gpio_cfgpin( (bit->scl), S3C2410_GPB4_OUTP);
	s3c2410_gpio_pullup( (bit->scl), 1); 
	s3c2410_gpio_cfgpin( (bit->sda), S3C2410_GPB3_OUTP);
	s3c2410_gpio_pullup( (bit->sda), 1); 
	s3c2410_gpio_cfgpin( (bit->l3_mode), S3C2410_GPB2_OUTP);
	s3c2410_gpio_pullup( (bit->l3_mode), 1); 
     

#if defined( CONFIG_ARCH_BIT2440) || defined (CONFIG_BOARD_S3C2440_SMDK)
	/* IIS gpio interface set */
	
dprintk("l3_2440 2\n");		
        /* GPE 0: I2SLRCK */
        s3c2410_gpio_cfgpin( S3C2410_GPE0, S3C2410_GPE0_I2SLRCK);
        s3c2410_gpio_pullup( S3C2410_GPE0, 0); 
        /* GPE 1: I2SSCLK */
        s3c2410_gpio_cfgpin( S3C2410_GPE1, S3C2410_GPE1_I2SSCLK);
        s3c2410_gpio_pullup( S3C2410_GPE1, 0); 
        /* GPE 2: CDCLK */
        s3c2410_gpio_cfgpin( S3C2410_GPE2, S3C2410_GPE2_CDCLK);
        s3c2410_gpio_pullup( S3C2410_GPE2, 0); 
        /* GPE 3: I2SSDI */
        s3c2410_gpio_cfgpin( S3C2410_GPE3, S3C2410_GPE3_I2SSDI);
        s3c2410_gpio_pullup( S3C2410_GPE3, 0); 
        /* GPE 4: I2SSDO */
        s3c2410_gpio_cfgpin( S3C2410_GPE4, S3C2410_GPE4_I2SSDO);
        s3c2410_gpio_pullup( S3C2410_GPE4, 0); 


#endif

	local_irq_restore(flags);

	ret = l3_start(bit);
	if (ret)
		l3_end();

	printk("GPIO L3 bus interface for S3C2440, installed\n");

	return ret;
}
Exemplo n.º 25
0
/**
 * usb_hcd_s3c2410_probe - initialize S3C2410-based HCDs
 * Context: !in_interrupt()
 *
 * Allocates basic resources for this USB host controller, and
 * then invokes the start() method for the HCD associated with it
 * through the hotplug entry's driver_data.
 *
 */
static int usb_hcd_s3c2410_probe (const struct hc_driver *driver,
				  struct platform_device *dev)
{
	struct usb_hcd *hcd = NULL;
	int retval;
#if defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
	/* USB host Power enable */
	s3c2410_gpio_cfgpin(S3C2410_GPB4, S3C2410_GPB4_OUTP);
	s3c2410_gpio_pullup(S3C2410_GPB4, 0);
	s3c2410_gpio_setpin(S3C2410_GPB4, 1);

#if (USB_HOST_PORT2_EN == 1)
	usb20_phy_init();
#endif
#endif

#if (USB_HOST_PORT2_EN == 1) && (CONFIG_PLAT_S3C64XX == 1)
	/* set USB_SIG_MASK */
	__raw_writel( __raw_readl(S3C_OTHERS)|(1<<16), S3C_OTHERS);

	/* Initializes OTG PHY */
	__raw_writel(0x0, S3C_USBOTG_PHYPWR);
	__raw_writel(0x60, S3C_USBOTG_PHYCLK);

	__raw_writel(0x1, S3C_USBOTG_RSTCON);	
	udelay(20);
	__raw_writel(0x0, S3C_USBOTG_RSTCON);
	udelay(20);
#endif

	s3c2410_usb_set_power(dev->dev.platform_data, 1, 1);
	s3c2410_usb_set_power(dev->dev.platform_data, 2, 1);

	hcd = usb_create_hcd(driver, &dev->dev, "s3c24xx");
	if (hcd == NULL)
		return -ENOMEM;

	hcd->rsrc_start = dev->resource[0].start;
	hcd->rsrc_len   = dev->resource[0].end - dev->resource[0].start + 1;

	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
		dev_err(&dev->dev, "request_mem_region failed");
		retval = -EBUSY;
		goto err_put;
	}

	clk = clk_get(&dev->dev, "usb-host");
	if (IS_ERR(clk)) {
		dev_err(&dev->dev, "cannot get usb-host clock\n");
		retval = -ENOENT;
		goto err_mem;
	}

#if (USB_HOST_PORT2_EN == 1) && (CONFIG_PLAT_S3C64XX == 1)
	otg_clk = clk_get(&dev->dev, "otg");
	if (IS_ERR(clk)) {
		dev_err(&dev->dev, "cannot get otg clock\n");
		retval = -ENOENT;
		goto err_mem;
	}
#endif

#if !defined(CONFIG_CPU_S3C6400) && !defined(CONFIG_CPU_S3C6410)
	usb_clk = clk_get(&dev->dev, "usb-bus-host");
	if (IS_ERR(usb_clk)) {
		dev_err(&dev->dev, "cannot get usb-host clock\n");
		retval = -ENOENT;
		goto err_clk;
	}
#endif
	s3c2410_start_hc(dev, hcd);

	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
	if (!hcd->regs) {
		dev_err(&dev->dev, "ioremap failed\n");
		retval = -ENOMEM;
		goto err_ioremap;
	}

	ohci_hcd_init(hcd_to_ohci(hcd));

	retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED);
	if (retval != 0)
		goto err_ioremap;

	return 0;

 err_ioremap:
	s3c2410_stop_hc(dev);
	iounmap(hcd->regs);
	clk_put(usb_clk);

#if !defined(CONFIG_CPU_S3C6400) && !defined(CONFIG_CPU_S3C6410)
 err_clk:
	clk_put(clk);
#endif

 err_mem:
	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);

 err_put:
	usb_put_hcd(hcd);
	return retval;
}
Exemplo n.º 26
0
/****************************************************************************
 * Module initialisation
 ****************************************************************************/
static int __init
register_quad (void)
{
  printk("RQUAD:%s module: loaded\n", acModuleName);

  /* Tell GPIO module which GPIO pins we are using */
  rgpio_register("GPG14,15 (inputs)", acModuleName);

  /* Set up GPIO pins
   * SHAFT0 = GPG14 (pin function = EINT22)
   * SHAFT1 = GPG15 (pin function = EINT23) */
  s3c2410_gpio_cfgpin(S3C2410_GPG14, S3C2410_GPG14_EINT22);
  s3c2410_gpio_cfgpin(S3C2410_GPG15, S3C2410_GPG15_EINT23);
  if (machine_is_rirm2())
  {
    // Enable internal pullups on Barracuda
    s3c2410_gpio_pullup(S3C2410_GPG14, 0);
    s3c2410_gpio_pullup(S3C2410_GPG15, 0);
  }
  else
  {
    // Disable internal pulldowns on Stingray
    s3c2410_gpio_pullup(S3C2410_GPG14, 1);
    s3c2410_gpio_pullup(S3C2410_GPG15, 1);
    // Enable external pullups on Stingray
    s3c2410_gpio_cfgpin(S3C2410_GPA5, S3C2410_GPA5_OUT);
    s3c2410_gpio_cfgpin(S3C2410_GPA7, S3C2410_GPA7_OUT);
    s3c2410_gpio_setpin(S3C2410_GPA5, 1);
    s3c2410_gpio_setpin(S3C2410_GPA7, 1);
  }
  
  if (machine_is_rirm2())
  {
    /* Enable interrupt on both pins (both edges) */
    rutl_regwrite((0xff << 24), 0, (int)S3C2410_EXTINT2);

    /* Set the length of filter for external interrupt
     * Filter clock = PCLK
     * Filter width = 0x7f (max) */
    rutl_regwrite(0x7f7f0000, 0xffff0000, (int)S3C2410_EINFLT3);
  }
  else
  {
    /* As above for Stingray */
    rutl_regwrite((0xff << 24), 0, (int)S3C2410_EXTINT2 + 0x10);
    rutl_regwrite(0x7f7f0000, 0xffff0000, (int)S3C2410_EINFLT3 + 0x10);
  }

  /* Note initial state of shaft encoder gpio pins */
  shaft_old = SHAFT_PINS;
  
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  /* Clear any start-up interrupts */
  if (machine_is_rirm2())
  {
    rutl_regwrite((22 << 1) | (23 << 1), 0, (int)S3C2410_EINTPEND);
  }
  else
  {
    rutl_regwrite((22 << 1) | (23 << 1), 0, (int)S3C2412_EINTPEND);
  }
#endif

  /* Set up input system */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
  input_dev = input_allocate_device();
#else
  input_dev = kmalloc (sizeof (*input_dev), GFP_KERNEL);
  memset (input_dev, 0, sizeof (*input_dev));
#endif
  input_dev->evbit[0] = BIT(EV_REL);
  set_bit (REL_Y, input_dev->relbit);
  input_dev->name = "reciva_quad";
  input_register_device (input_dev);

  /* Set up the interrupts */
  request_irq(IRQ_EINT22, reciva_quad_int_handler, 0, "EINT22", (void *)22);
  request_irq(IRQ_EINT23, reciva_quad_int_handler, 0, "EINT23", (void *)23);

  return 0;
}
Exemplo n.º 27
0
//static int wm8350_init(struct wm8350 *wm8350)
int wm8350_dev_init(struct wm8350 *wm8350)
{
	int i, ret;
	u16 data;

#if 0
	/* dont assert RTS when hibernating */
	wm8350_set_bits(wm8350, WM8350_SYSTEM_HIBERNATE, WM8350_RST_HIB_MODE);
#endif

	wm8350_reg_unlock(wm8350);
	wm8350_set_bits(wm8350, WM8350_SYSTEM_CONTROL_1, WM8350_IRQ_POL);
	wm8350_reg_lock(wm8350);

	s3c2410_gpio_pullup(S3C2410_GPF1, 0);
	s3c2410_gpio_cfgpin(S3C2410_GPF1, S3C2410_GPF1_EINT1);
//	set_irq_type(IRQ_EINT1, IRQT_BOTHEDGE);
	s3c2410_gpio_pullup(S3C2410_GPF2, 0);
	s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_EINT2);

	/* Shutdown threshold value 3.1v off , 3.2v on */
	wm8350_reg_unlock(wm8350);
	data = wm8350_reg_read(wm8350, WM8350_POWER_CHECK_COMPARATOR)
		& ~(WM8350_PCCMP_OFF_THR_MASK | WM8350_PCCMP_ON_THR_MASK);
	wm8350_reg_write(wm8350, WM8350_POWER_CHECK_COMPARATOR, data | 0x23);
	wm8350_reg_lock(wm8350);

	data = wm8350_reg_read(wm8350, WM8350_DIGITISER_CONTROL_2);
	wm8350_reg_write(wm8350, WM8350_DIGITISER_CONTROL_2, data | WM8350_AUXADC_CAL);

	config_s3c_wm8350_gpio(wm8350);

#if 0
	/* Sw1 --> PWR_ON */
	wm8350_register_irq(wm8350, WM8350_IRQ_WKUP_ONKEY,
			    imx32ads_switch_handler, NULL);
	wm8350_unmask_irq(wm8350, WM8350_IRQ_WKUP_ONKEY);
#endif

#ifndef CONFIG_MACH_CANOPUS
	for (i = 0; i < ARRAY_SIZE(wm8350_regulator_devices); i++) {
		platform_set_drvdata(&wm8350_regulator_devices[i], wm8350);
		ret = platform_device_register(&wm8350_regulator_devices[i]);
		if (ret < 0)
			goto unwind;
	}
#else	// CONFIG_MACH_CANOPUS
	struct regulator_init_data *reg_data = NULL;

	for (i = 0; i < ARRAY_SIZE(wm8350_regulator_devices); i++) {
		if (wm8350_regulator_devices[i].id == WM8350_DCDC_4) {
			// for LCD
			if (q_hw_ver(7800_ES2)
					|| q_hw_ver(7800_TP)
					|| q_hw_ver(7800_MP)) {
				reg_data = (struct regulator_init_data *)wm8350_regulator_devices[i].dev.platform_data;
				reg_data->constraints.min_uV = 3400000;
				reg_data->constraints.max_uV = 3400000;
				reg_data->constraints.state_mem.uV = 3400000;
			}
		} else if (wm8350_regulator_devices[i].id == WM8350_LDO_3) {
			// for PMIC LDO
			if (q_hw_ver(SWP2000)
					|| q_hw_ver(7800_MP2)
					|| q_hw_ver(KTQOOK_TP2)
					|| q_hw_ver(KTQOOK_MP)
					|| q_hw_ver(SKATM)) {
				reg_data = (struct regulator_init_data *)wm8350_regulator_devices[i].dev.platform_data;

				reg_data->constraints.min_uV = 1200000;
				reg_data->constraints.max_uV = 1200000;
				reg_data->num_consumer_supplies = ARRAY_SIZE(ldo4_consumers);
				reg_data->consumer_supplies = ldo4_consumers;
			}
		} else if (wm8350_regulator_devices[i].id == WM8350_LDO_4) {
			// for PMIC LDO
			if (q_hw_ver(SWP2000)
					|| q_hw_ver(7800_MP2)
					|| q_hw_ver(KTQOOK_TP2)
					|| q_hw_ver(KTQOOK_MP)
					|| q_hw_ver(SKATM)) {
				reg_data = (struct regulator_init_data *)wm8350_regulator_devices[i].dev.platform_data;
				reg_data->constraints.min_uV = 3300000;
				reg_data->constraints.max_uV = 3300000;
				reg_data->num_consumer_supplies = ARRAY_SIZE(ldo3_consumers);
				reg_data->consumer_supplies = ldo3_consumers;
			}
		}

		platform_set_drvdata(&wm8350_regulator_devices[i], wm8350);
		ret = platform_device_register(&wm8350_regulator_devices[i]);
		if (ret < 0)
			goto unwind;
	}
#endif	// CONFIG_MACH_CANOPUS

	/* now register other clients */
	return s3c_wm8350_device_register(wm8350);
unwind:
	for (i--; i >= 0; i--)
		platform_device_unregister(&wm8350_regulator_devices[i]);

	return ret;
}
Exemplo n.º 28
0
static int s3c_i2s_hw_params(struct snd_pcm_substream *substream,
				struct snd_pcm_hw_params *params)
{
	struct snd_soc_pcm_runtime *rtd = substream->private_data;

	unsigned long iiscon;
	unsigned long iismod;
	unsigned long iisfcon;
	s3cdbg("Entered %s\n", __FUNCTION__);

	writel((readl(S3C2410_MISCCR) & ~(7<<8))|(1<<8), S3C2410_MISCCR);

	/*Set I2C port to controll WM8753 codec*/
	s3c2410_gpio_pullup(S3C2410_GPE15, 0);
	s3c2410_gpio_pullup(S3C2410_GPE14, 0);
	s3c2410_gpio_cfgpin(S3C2410_GPE15, S3C2410_GPE15_IICSDA);
	s3c2410_gpio_cfgpin(S3C2410_GPE14, S3C2410_GPE14_IICSCL);

#if defined CONFIG_SND_SOC_I2S_V40
	/* Configure the I2S pins in correct mode */
	writel(0x0, S3C2450_GPESEL);

	s3c2410_gpio_cfgpin(S3C2410_GPE0, S3C2410_GPE0_I2SLRCK);
	s3c2410_gpio_cfgpin(S3C2410_GPE1, S3C2410_GPE1_I2SSCLK);
	s3c2410_gpio_cfgpin(S3C2410_GPE2, S3C2410_GPE2_CDCLK);
	s3c2410_gpio_cfgpin(S3C2410_GPE3, S3C2410_GPE3_I2SSDI);
	s3c2410_gpio_cfgpin(S3C2410_GPE4, S3C2410_GPE4_I2SSDO);

	writel(readl(S3C2410_GPEUP)| 0x3ff, S3C2410_GPEUP);

	writel(readl(S3C2450_GPBSEL)|(0x3<<3), S3C2450_GPBSEL);
	writel(readl(S3C2410_GPBUP)|(0xF<<18), S3C2410_GPBUP);

#elif defined CONFIG_SND_SOC_I2S_V32
	/* Configure the I2S pins in correct mode */
	writel(0x0, S3C2450_GPLSEL);

	s3c2410_gpio_cfgpin(S3C2410_GPL4, S3C2450_GPL4_I2S1_SCLK);
	s3c2410_gpio_cfgpin(S3C2410_GPL5, S3C2450_GPL5_I2S1_CDCLK);
	s3c2410_gpio_cfgpin(S3C2410_GPL6, S3C2450_GPL6_I2S1_SDI);
	s3c2410_gpio_cfgpin(S3C2410_GPL7, S3C2450_GPL7_I2S1_SDO);
	s3c2410_gpio_cfgpin(S3C2443_GPJ13, S3C2450_GPJ13_I2S1_LRCK);

	writel(readl(S3C2410_GPLUP)| (0xf<<4), S3C2410_GPLUP);
	writel(readl(S3C2443_GPJDN)| (0x3<<26), S3C2443_GPJDN);

#else
	printk("Error: S3C2450 I2S configration \n",);
#endif

	if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) {
		rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_out;
	} else {
		rtd->dai->cpu_dai->dma_data = &s3c24xx_i2s_pcm_stereo_in;
	}

	/* Working copies of registers */
	iiscon = readl(s3c24xx_i2s.regs + S3C2410_IISCON);
	iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD);
	iisfcon = readl(s3c24xx_i2s.regs + S3C2443_IISFIC);

	iiscon |= S3C_IIS0CON_TXDMACTIVE;
	iiscon |= S3C_IIS0CON_RXDMACTIVE;

	iismod &= ~S3C_IIS0MOD_CLK_MASK;
	iismod |= S3C_IIS0MOD_IMS_EXTERNAL_MASTER| S3C_IIS0MOD_INTERNAL_CLK;
	iismod &= ~S3C_IIS0MOD_MODE_MASK;
	iismod |= S3C_IIS0MOD_TXRXMODE;

	/* Multi channel enable */
	iismod &= ~S3C_IIS0MOD_DCE_MASK;
	switch (params_channels(params)) {
	case 6:
		printk("s3c i2s: 5.1channel\n");
		iismod |= S3C_IIS0MOD_DCE_SD1;
		iismod |= S3C_IIS0MOD_DCE_SD2;
		break;
	case 4:
		printk("s3c i2s: 4 channel\n");
		iismod |= S3C_IIS0MOD_DCE_SD1;
		break;
	case 2:
		printk("s3c i2s: 2 channel\n");
		break;
	default:
		printk(KERN_ERR "s3c-i2s-v40: %d channels unsupported\n",
		       params_channels(params));
		return -EINVAL;
	}

	/* Set the bit rate */
#if 0
	iismod &= ~0x6000;
#endif
	switch (params_format(params)) {
	case SNDRV_PCM_FORMAT_S8:
		iismod |= S3C_IIS0MOD_8BIT;
		iismod &= ~S3C_IIS0MOD_BFS_MASK;
		iismod |= S3C_IIS0MOD_32FS;
		iismod &= ~S3C_IIS0MOD_FS_MASK;
		iismod |= S3C_IIS0MOD_384FS;
		break;
	case SNDRV_PCM_FORMAT_S16_LE:
		iismod &= ~S3C_IIS0MOD_FS_MASK;
		iismod &= ~S3C_IIS0MOD_BFS_MASK;
		iismod |= S3C_IIS0MOD_384FS | S3C_IIS0MOD_32FS;
		iismod &= ~S3C_IIS0MOD_BLC_MASK;
		iismod |= S3C_IIS0MOD_16BIT;
		break;
	case SNDRV_PCM_FORMAT_S24_LE:
		iismod &= ~S3C_IIS0MOD_FS_MASK;
		iismod &= ~S3C_IIS0MOD_BFS_MASK;
		iismod |= S3C_IIS0MOD_384FS | S3C_IIS0MOD_48FS;
		iismod &= ~S3C_IIS0MOD_BLC_MASK;
		iismod |= S3C_IIS0MOD_24BIT;
		break;
	default:
		return -EINVAL;
	}


	iisfcon |= S3C_IIS_TX_FLUSH;
	iisfcon |= S3C_IIS_RX_FLUSH;

	writel(iiscon, s3c24xx_i2s.regs + S3C2410_IISCON);
	iismod &= ~S3C_IIS0MOD_FM_MASK;
	writel(iismod, s3c24xx_i2s.regs + S3C2410_IISMOD);
	writel(iisfcon, s3c24xx_i2s.regs + S3C2443_IISFIC);

	/* Tx, Rx fifo flush bit clear */
	iisfcon  &= ~(S3C_IIS_TX_FLUSH | S3C_IIS_RX_FLUSH);
	writel(iisfcon, s3c24xx_i2s.regs + S3C2443_IISFIC);

	s3cdbg("s3c iis mode: 0x%08x\n", readl(s3c24xx_i2s.regs + S3C2410_IISMOD));
	s3cdbg("s3c: params_channels %d\n", params_channels(params));
	s3cdbg("s3c: params_format %d\n", params_format(params));
	s3cdbg("s3c: params_subformat %d\n", params_subformat(params));
	s3cdbg("s3c: params_period_size %d\n", params_period_size(params));
	s3cdbg("s3c: params_period_bytes %d\n", params_period_bytes(params));
	s3cdbg("s3c: params_periods %d\n", params_periods(params));
	s3cdbg("s3c: params_buffer_size %d\n", params_buffer_size(params));
	s3cdbg("s3c: params_buffer_bytes %d\n", params_buffer_bytes(params));
	s3cdbg("s3c: params_tick_time %d\n", params_tick_time(params));

	return 0;
}
Exemplo n.º 29
0
/* until it's enabled, this UDC should be completely invisible
 * to any USB host.
 */
static int udc_enable(struct s3c_udc *dev)
{
	DEBUG_SETUP("%s: %p\n", __FUNCTION__, dev);

	/* usb power enable, vbus detect pull-up/down disable */
#if defined(CONFIG_CPU_S3C2450) || defined(CONFIG_CPU_S3C2416)
	s3c2410_gpio_pullup(S3C2443_GPH14, 2); /* usb power pull-up enable */
	s3c2410_gpio_pullup(S3C2410_GPF2, 0);  /* vbus detect pull-up/down disable */
#else
	s3c2410_gpio_pullup(S3C2443_GPH14, 0); /* usb power pull-up enable */
#endif
	s3c2410_gpio_cfgpin(S3C2443_GPH14, S3C2443_GPH14_OUTP);
	s3c2410_gpio_setpin(S3C2443_GPH14, 1); 	/* usb power enbale */

	mdelay(1);

	/* if reset by sleep wakeup, control the retention I/O cell */
	if (__raw_readl(S3C_RSTSTAT) & 0x8)
		__raw_writel(__raw_readl(S3C_RSTCON)|(1<<16), S3C_RSTCON);

	/* USB Port is Normal mode */
	__raw_writel(__raw_readl(S3C2410_MISCCR)&~(1<<12), S3C2410_MISCCR);

	/* PHY power enable */
	__raw_writel(__raw_readl(S3C_PWRCFG)|(1<<4), S3C_PWRCFG);

	/* USB device 2.0 must reset like bellow,
	 * 1st phy reset and after at least 10us, func_reset & host reset
	 * phy reset can reset bellow registers.
	 */
	/* PHY 2.0 S/W reset */
	__raw_writel((0<<2)|(0<<1)|(1<<0), S3C_URSTCON);
	mdelay(1); /* phy reset must be asserted for at 10us */
	
	/*Function 2.0, Host 1.1 S/W reset*/
	__raw_writel((1<<2)|(1<<1)|(0<<0), S3C_URSTCON);
	__raw_writel((0<<2)|(0<<1)|(0<<0), S3C_URSTCON);
	
	/* 48Mhz,Oscillator,External X-tal,device */
	__raw_writel((0<<3)|(1<<2)|(1<<1)|(0<<0), S3C_PHYCTRL);

	/* 48Mhz clock on ,PHY2.0 analog block power on
	 * XO block power on,XO block power in suspend mode,
	 * PHY 2.0 Pll power on ,suspend signal for save mode disable
	 */
	__raw_writel((1<<31)|(0<<4)|(0<<3)|(0<<2)|(0<<1)|(0<<0), S3C_PHYPWR);

	/* D+ pull up disable(VBUS detect), USB2.0 Function clock Enable,
	 * USB1.1 HOST disable, USB2.0 PHY test enable
	 */
	__raw_writel((0<<31)|(1<<2)|(0<<1)|(1<<0), S3C_UCLKCON);

	__raw_writel(IRQ_USBD, S3C2410_INTPND);
	__raw_writel(IRQ_USBD, S3C2410_SRCPND);

	reconfig_usbd();
	
	__raw_writel(__raw_readl(S3C2410_INTMSK)&~(IRQ_USBD), S3C2410_INTMSK);

	/* D+ pull up , USB2.0 Function clock Enable,
	 * USB1.1 HOST disable,USB2.0 PHY test enable
	 */
	__raw_writel((1<<31)|(1<<2)|(0<<1)|(1<<0), S3C_UCLKCON);
	
	DEBUG_SETUP("S3C2443 USB Controller Core Initialized\n");
	
	dev->gadget.speed = USB_SPEED_UNKNOWN;

	return 0;
}
Exemplo n.º 30
0
/****************************************************************************
 * Module initialisation
 ****************************************************************************/
static int __init
register_quad (void)
{
  printk(PFX "register_quad\n");
  printk(PFX "  pin_config=%d\n", pin_config);
  printk(PFX "  pin_config_23=%d\n", pin_config_23);
  printk(PFX "  [0].pulse_threshold=%d\n", pulse_threshold);
  printk(PFX "  [0].pins_reversed=%d\n", pins_reversed);
  printk(PFX "  [1].pulse_threshold=%d\n", pulse_threshold_23);
  printk(PFX "  [1].pins_reversed=%d\n", pins_reversed_23);

  memset(encoders, 0, sizeof(encoders));

  encoders[0].pin0_irq_name = "shaft0";
  encoders[0].pin1_irq_name = "shaft1";
  encoders[0].device_name = "reciva_quad";
  encoders[0].pulse_threshold = pulse_threshold;
  encoders[0].pins_reversed = pins_reversed;
  encoders[0].direction_old = 'x';
  encoders[0].rel_event_id = REL_Y;

  encoders[1].pin0_irq_name = "shaft2";
  encoders[1].pin1_irq_name = "shaft3";
  encoders[1].device_name = "reciva_quad2";
  encoders[1].pulse_threshold = pulse_threshold_23;
  encoders[1].pins_reversed = pins_reversed_23;
  encoders[1].direction_old = 'x';
  encoders[1].rel_event_id = REL_Z;

  /* Work out which GPIO pins we're using (SHAFT0/1) */
  switch (pin_config)
  {
    case 0:
      /* SHAFT0 = GPG14 (pin function = EINT22)
       * SHAFT1 = GPG15 (pin function = EINT23) */
      encoders[0].active = 1;
      encoders[0].pin0 = S3C2410_GPG14;
      encoders[0].pin1 = S3C2410_GPG15;
      encoders[0].eint0 = S3C2410_GPG14_EINT22;
      encoders[0].eint1 = S3C2410_GPG15_EINT23;
      encoders[0].irq_pin0 = IRQ_EINT22;
      encoders[0].irq_pin1 = IRQ_EINT23;
      break;
    case 1:  
      /* SHAFT0 = GPG3 (pin function = EINT11)
       * SHAFT1 = GPG5 (pin function = EINT13) */
      encoders[0].active = 1;
      encoders[0].pin0 = S3C2410_GPG3;
      encoders[0].pin1 = S3C2410_GPG5;
      encoders[0].eint0 = S3C2410_GPG3_EINT11;
      encoders[0].eint1 = S3C2410_GPG5_EINT13;
      encoders[0].irq_pin0 = IRQ_EINT11;
      encoders[0].irq_pin1 = IRQ_EINT13;
      break;
    case 2:  
      /* SHAFT0 = GPG5 (pin function = EINT13)
       * SHAFT1 = GPG7 (pin function = EINT15) */
      encoders[0].active = 1;
      encoders[0].pin0 = S3C2410_GPG5;
      encoders[0].pin1 = S3C2410_GPG7;
      encoders[0].eint0 = S3C2410_GPG5_EINT13;
      encoders[0].eint1 = S3C2410_GPG7_EINT15;
      encoders[0].irq_pin0 = IRQ_EINT13;
      encoders[0].irq_pin1 = IRQ_EINT15;
      break;

    default:
      return -ENODEV;
  }

  /* Work out which GPIO pins we're using (SHAFT2/3) */
  switch (pin_config_23)
  {
    case 0:
      break;
    case 1:
      encoders[1].active = 1;
      encoders[1].pin0 = S3C2410_GPG11;
      encoders[1].pin1 = S3C2410_GPG10;
      encoders[1].eint0 = S3C2410_GPG11_EINT19;
      encoders[1].eint1 = S3C2410_GPG10_EINT18;
      encoders[1].irq_pin0 = IRQ_EINT19;
      encoders[1].irq_pin1 = IRQ_EINT18;
      break;
    case 2:
      encoders[1].active = 1;
      encoders[1].pin0 = S3C2410_GPG3;
      encoders[1].pin1 = S3C2410_GPF4;
      encoders[1].eint0 = S3C2410_GPG3_EINT11;
      encoders[1].eint1 = S3C2410_GPF4_EINT4;
      encoders[1].irq_pin0 = IRQ_EINT11;
      encoders[1].irq_pin1 = IRQ_EINT4;
      break;
    case 3:
      encoders[1].active = 1;

      encoders[1].pin0 = S3C2410_GPG3;
      encoders[1].eint0 = S3C2410_GPG3_EINT11;
      encoders[1].irq_pin0 = IRQ_EINT11;

      if (machine_is_rirm3())
      {
        encoders[1].pin1 = S3C2410_GPG0;
        encoders[1].eint1 = S3C2410_GPG0_EINT8;
        encoders[1].irq_pin1 = IRQ_EINT8;
      }
      else
      {
        encoders[1].pin1 = S3C2410_GPG5;
        encoders[1].eint1 = S3C2410_GPG5_EINT13;
        encoders[1].irq_pin1 = IRQ_EINT13;
      }
      break;
    default:
      return -ENODEV;
  }

  /* Configure GPIO */
  int i;
  for (i=0; i<MAX_ENCODERS; i++)  
  {
    if (encoders[i].active)
    {
      s3c2410_gpio_cfgpin(encoders[i].pin0, encoders[i].eint0);
      s3c2410_gpio_cfgpin(encoders[i].pin1, encoders[i].eint1);
      // Enable pullups on Barracuda, disable pulldowns on Stingray
      int pull = machine_is_rirm2() ? 0 : 1;
      s3c2410_gpio_pullup(encoders[i].pin0, pull);
      s3c2410_gpio_pullup(encoders[i].pin1, pull);
    }
  }

  if ((pin_config==0) && machine_is_rirm3())
  {
    // Enable external pullups on Stingray
    s3c2410_gpio_cfgpin(S3C2410_GPA5, S3C2410_GPA5_OUT);
    s3c2410_gpio_cfgpin(S3C2410_GPA7, S3C2410_GPA7_OUT);
    s3c2410_gpio_setpin(S3C2410_GPA5, 1);
    s3c2410_gpio_setpin(S3C2410_GPA7, 1);
  }

  /* Enable interrupts - SHAFT0/1 */
  // Stingray fiddle for Samsung changing the external interrupt addresses
  int eint_adjust = machine_is_rirm2() ? 0 : 0x10;
  switch (pin_config)
  {
    case 0:
      /* Enable interrupt on both pins (both edges)
       * Don't need to clear bits as we're setting all that we're interested in */
      rutl_regwrite(0xff000000,  // Set
                    0,           // Clear 
                    (int)S3C2410_EXTINT2 + eint_adjust);

      /* Set the length of filter for external interrupt
       * Filter clock = PCLK
       * Filter width = 0x7f (max) */
      rutl_regwrite(0x7f7f0000,  // Set
                    0xffff0000,  // Clear 
                    (int)S3C2410_EINFLT3 + eint_adjust);
      break;
    case 1:
      /* Enable interrupt on both pins (both edges)
       * Don't need to clear bits as we're setting all that we're interested in */
      rutl_regwrite((7 << 20) | (7 << 12),  // Set
                    0,                      // Clear 
                    (int)S3C2410_EXTINT1 + eint_adjust);
      break;
    case 2:
      /* Enable interrupt on both pins (both edges)
       * Don't need to clear bits as we're setting all that we're interested in */
      rutl_regwrite((7 << 28) | (7 << 20),  // Set
                    0,           // Clear 
                    (int)S3C2410_EXTINT1 + eint_adjust);
      break;
    default:
      BUG ();
  }

  /* Enable interrupts - SHAFT2/3 */
  switch (pin_config_23)
  {
    case 0:
      break;
    case 1:
      /* Enable interrupt on both pins (both edges)
       * Don't need to clear bits as we're setting all that we're interested in */
      rutl_regwrite((7 << 8) | (7 << 12),   // Set
                    0,                      // Clear 
                    (int)S3C2410_EXTINT2 + eint_adjust);
      break;
    case 2:
      // GPF4 - EINT4  
      rutl_regwrite((7 << 16),              // Set
                    0,                      // Clear 
                    (int)S3C2410_EXTINT0 + eint_adjust);
      // GPG3 - EINT11
      rutl_regwrite((7 << 12),   // Set
                    0,                      // Clear 
                    (int)S3C2410_EXTINT1 + eint_adjust);
      break;
    case 3:
      if (machine_is_rirm3())
      {
        // GPG0 - EINT8
        rutl_regwrite((7 << 0),   // Set
                      0,                      // Clear 
                      (int)S3C2410_EXTINT1 + eint_adjust);
      }
      else
      {
        // GPG5 - EINT13
        rutl_regwrite((7 << 20),   // Set
                      0,                      // Clear 
                      (int)S3C2410_EXTINT1 + eint_adjust);
      }

      // GPG3 - EINT11
      rutl_regwrite((7 << 12),   // Set
                    0,                      // Clear 
                    (int)S3C2410_EXTINT1 + eint_adjust);
      break;
    default:
      BUG ();
  }

  /* Request IRQs and set up input system */
  for (i=0; i<MAX_ENCODERS; i++)
  {
    if (encoders[i].active)
    {
      /* Note initial state of shaft encoder gpio pins */
      encoders[i].shaft_old = reciva_qp_pins_read(&encoders[i]);

      /* Set up input system */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
      encoders[i].input_dev = input_allocate_device();
#else
      encoders[i].input_dev = kmalloc (sizeof (*encoders[i].input_dev), GFP_KERNEL);
      memset (encoders[i].input_dev, 0, sizeof (*encoders[i].input_dev));
#endif
      encoders[i].input_dev->evbit[0] = BIT(EV_REL);
      set_bit (encoders[i].rel_event_id, encoders[i].input_dev->relbit);
      encoders[i].input_dev->name = encoders[i].device_name;
      input_register_device (encoders[i].input_dev);

      /* Set up the interrupts */
      request_irq(encoders[i].irq_pin0, reciva_quad_int_handler, 0, encoders[i].pin0_irq_name, NULL);
      request_irq(encoders[i].irq_pin1, reciva_quad_int_handler, 0, encoders[i].pin1_irq_name, NULL);
    }
  }
  return 0;
}