Beispiel #1
0
static int scx200_i2c_init(void)
{
	pr_debug("NatSemi SCx200 I2C Driver\n");

	if (!scx200_gpio_present()) {
		pr_err("no SCx200 gpio pins available\n");
		return -ENODEV;
	}

	pr_debug("SCL=GPIO%02u, SDA=GPIO%02u\n", scl, sda);

	if (scl == -1 || sda == -1 || scl == sda) {
		pr_err("scl and sda must be specified\n");
		return -EINVAL;
	}

	/* Configure GPIOs as open collector outputs */
	scx200_gpio_configure(scl, ~2, 5);
	scx200_gpio_configure(sda, ~2, 5);

	if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) {
		pr_err("adapter %s registration failed\n", scx200_i2c_ops.name);
		return -ENODEV;
	}
	
	return 0;
}
Beispiel #2
0
static int scx200_i2c_init(void)
{
	pr_debug(NAME ": NatSemi SCx200 I2C Driver\n");

	if (!scx200_gpio_present()) {
;
		return -ENODEV;
	}

	pr_debug(NAME ": SCL=GPIO%02u, SDA=GPIO%02u\n", scl, sda);

	if (scl == -1 || sda == -1 || scl == sda) {
;
		return -EINVAL;
	}

	/* Configure GPIOs as open collector outputs */
	scx200_gpio_configure(scl, ~2, 5);
	scx200_gpio_configure(sda, ~2, 5);

	if (i2c_bit_add_bus(&scx200_i2c_ops) < 0) {
//		printk(KERN_ERR NAME ": adapter %s registration failed\n", 
;
		return -ENODEV;
	}
	
	return 0;
}
Beispiel #3
0
void scx200_gpio_dump(unsigned index)
{
	u32 config = scx200_gpio_configure(index, ~0, 0);
	printk(KERN_DEBUG "GPIO%02u: 0x%08lx", index, (unsigned long)config);
	
	if (config & 1) 
		printk(" OE"); /* output enabled */
	else
		printk(" TS"); /* tristate */
	if (config & 2) 
		printk(" PP"); /* push pull */
	else
		printk(" OD"); /* open drain */
	if (config & 4) 
		printk(" PUE"); /* pull up enabled */
	else
		printk(" PUD"); /* pull up disabled */
	if (config & 8) 
		printk(" LOCKED"); /* locked */
	if (config & 16) 
		printk(" LEVEL"); /* level input */
	else
		printk(" EDGE"); /* edge input */
	if (config & 32) 
		printk(" HI"); /* trigger on rising edge */
	else
		printk(" LO"); /* trigger on falling edge */
	if (config & 64) 
		printk(" DEBOUNCE"); /* debounce */
	printk("\n");
}