Exemplo n.º 1
0
static inline int bmg160_bus_config(struct device *dev)
{
	const struct bmg160_device_config *dev_cfg = dev->config->config_info;
	struct bmg160_device_data *bmg160 = dev->driver_data;
	u32_t i2c_cfg;

	i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(dev_cfg->i2c_speed);

	return i2c_configure(bmg160->i2c, i2c_cfg);
}
Exemplo n.º 2
0
void taskA(void)
{
	int rc1;
	int rc2;
	gpio = device_get_binding(CONFIG_GPIO_PCAL9535A_1_DEV_NAME);
	gpio_sus = device_get_binding(CONFIG_GPIO_SCH_1_DEV_NAME);
	i2c = device_get_binding(CONFIG_GPIO_PCAL9535A_1_I2C_MASTER_DEV_NAME);
	pinmux = device_get_binding(PINMUX_NAME);
	if (!i2c) {
		PRINT("I2C not found!!\n");
	} else {
		rc1 = i2c_configure(i2c, (I2C_SPEED_FAST << 1) | I2C_MODE_MASTER);
		if (rc1 != DEV_OK) {
			PRINT("I2C configuration error: %d\n", rc1);
		}
	}
	if (!gpio) {
		PRINT("GPIO not found!!\n");
	} else {
		rc1 = gpio_pin_configure(gpio, 6, GPIO_DIR_OUT);
		rc2 = gpio_pin_configure(gpio, 8, GPIO_DIR_OUT);
		if (rc1 != DEV_OK ||
		    rc2 != DEV_OK) {
			PRINT("GPIO config error %d, %d!!\n", rc1, rc2);
		}
	}
	if (!gpio_sus) {
		PRINT("Legacy GPIO not found!!\n");
	} else {
		rc1 = gpio_pin_configure(gpio_sus, 5, GPIO_DIR_OUT);
		if (rc1 != DEV_OK) {
			PRINT("Legacy GPIO config error %d!!\n", rc1);
		}
	}
	if (!pinmux) {
		PRINT("Pinmux device not found!\n");
	} else {
		/*
		 * By default pin D13 (pin 5 on Legacy GPIO_SUS
		 * is configured for input. To blink it, it needs to
		 * be configured for output
		 */
		rc1 = pinmux_pin_set(pinmux, 13, PINMUX_FUNC_A);
		if (rc1 != DEV_OK) {
			PRINT("Pinmux config error %d!!\n", rc1);
		}
	}

	/* taskA gives its own semaphore, allowing it to say hello right away */
	task_sem_give(TASKASEM);

	/* invoke routine that allows task to ping-pong hello messages with taskB */
	helloLoop(__FUNCTION__, TASKASEM, TASKBSEM);
}
Exemplo n.º 3
0
static inline int bmg160_bus_config(struct device *dev)
{
	const struct bmg160_device_config *dev_cfg = dev->config->config_info;
	struct bmg160_device_data *bmg160 = dev->driver_data;
	union dev_config i2c_cfg;

	i2c_cfg.raw = 0;
	i2c_cfg.bits.is_master_device = 1;
	i2c_cfg.bits.speed = dev_cfg->i2c_speed;

	return i2c_configure(bmg160->i2c, i2c_cfg.raw);
}
Exemplo n.º 4
0
int ataes132a_init(struct device *dev)
{
	struct ataes132a_device_data *ataes132a = dev->driver_data;
	const struct ataes132a_device_config *cfg = dev->config->config_info;
	u32_t i2c_cfg;

	SYS_LOG_DBG("ATAES132A INIT");

	ataes132a->i2c = device_get_binding((char *)cfg->i2c_port);
	if (!ataes132a->i2c) {
		SYS_LOG_DBG("ATAE132A master controller not found!");
		return -EINVAL;
	}

	i2c_cfg = I2C_MODE_MASTER | I2C_SPEED_SET(ATAES132A_BUS_SPEED);

	i2c_configure(ataes132a->i2c, i2c_cfg);

	k_sem_init(&ataes132a->device_sem, 1, UINT_MAX);

	ataes132a_init_states();

	return 0;
}
Exemplo n.º 5
0
int setup (void)
    {
    int status;
    int i;

    /* get the device bindings */

    /* On-chip Quark GPIO */
    gpio07 = device_get_binding(CONFIG_GPIO_DW_0_NAME);            // GPIO[7:0]
    gpioLegacy = device_get_binding(CONFIG_GPIO_MMIO_0_DEV_NAME);  // GPIO[9:8]
    gpio_sus = device_get_binding(CONFIG_GPIO_MMIO_1_DEV_NAME);  //GPIO_SUS[5:0]

    /* external components */
    gpioEXP0 = device_get_binding(CONFIG_GPIO_PCAL9535A_0_DEV_NAME);
    gpioEXP1 = device_get_binding(CONFIG_GPIO_PCAL9535A_1_DEV_NAME);
    gpioEXP2 = device_get_binding(CONFIG_GPIO_PCAL9535A_2_DEV_NAME);

    /* i2c master of gpioEXP0/1/2 */
    i2c = device_get_binding(CONFIG_GPIO_PCAL9535A_1_I2C_MASTER_DEV_NAME);

    pinmux = device_get_binding(PINMUX_NAME);

    if (!gpio07)
        {
        PRINT("GPIO DW not found!!\n");
        }

    if (!gpioLegacy)
        {
        PRINT("GPIO MMIO 0 not found!!\n");
        }

    if (!gpio_sus)
        {
        PRINT("GPIO MMIO 1 not found!!\n");
        }

    if (!gpioEXP0)
        {
        PRINT("EXP0 not found!!\n");
        }

    if (!gpioEXP1)
        {
        PRINT("EXP1 not found!!\n");
        }

    if (!gpioEXP2)
        {
        PRINT("EXP2 not found!!\n");
        }

    if (!i2c)
        {
        PRINT("I2C not found!!\n");
        }

    if (!pinmux)
        {
        PRINT("Pinmux not found!!\n");
        }

    if (!(gpio07 && gpioLegacy && gpio_sus && gpioEXP0 &&
          gpioEXP1 && gpioEXP2 && i2c && pinmux))
        {
        PRINT("Stopped.\n");
        return(DEV_FAIL);
        }

    status = i2c_configure(i2c, (I2C_SPEED_FAST << 1) | I2C_MODE_MASTER);

    if (status != DEV_OK)
        {
        PRINT("I2C configuration error: %d Stopped.\n", status);
        return(DEV_FAIL);
        }

    for (i=0; i < NUM_IO_PINS_USED; i++)
        {
        status =
            pinmux_set_pin(pinmux, mux_config[i].pin_num, mux_config[i].mode);

        if (status != DEV_OK)
            {
            PRINT("Pin %d not configured!! Stopped.\n", mux_config[i].pin_num);
            return(DEV_FAIL);
            }
        else
            PRINT("Pin %d configured\n", mux_config[i].pin_num);

        }

    return(DEV_OK);

    }
Exemplo n.º 6
0
/*!
 * zasevb_tcd_mod_init() - initial tcd setup
 * This performs the platform specific hardware setup for the MX2ADS.
 */
int zasevb_tcd_mod_init (void)
{
	int i2c = 1;
        int gpio = 1;

        /* ------------------------------------------------------------------------ */
	#ifdef CONFIG_OTG_ZASEVB_DIFFERENTIAL_UNIDIRECTIONAL
        int hwmode = XCVR_D_SE0_NEW;   
	int newmode = XCVR_D_D;		
	isp1301_tx_mode_t tx_mode = vp_vm_unidirectional;	// MXC91231 ok
	printk (KERN_INFO"Current setting is DIFFERENTIAL UNIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_UNIDIRECTIONAL
        int hwmode = XCVR_SE0_D_NEW;   
	int newmode = XCVR_SE0_D_NEW;
        isp1301_tx_mode_t tx_mode = dat_se0_unidirectional;     //  MXC91331 ok
	printk (KERN_INFO"Current setting is SINGLE ENDED UNIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_DIFFERENTIAL_BIDIRECTIONAL
	int hwmode = XCVR_D_D;
        int newmode = XCVR_D_D;
	isp1301_tx_mode_t tx_mode = vp_vm_bidirectional;       // MXC91331 ok
        printk (KERN_INFO"Current setting is DIFFERENTIAL BIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
	#elif CONFIG_OTG_ZASEVB_SINGLE_ENDED_BIDIRECTIONAL
        int hwmode = XCVR_SE0_SE0;   
	int newmode = XCVR_SE0_SE0;
        isp1301_tx_mode_t tx_mode = dat_se0_bidirectional;	//MXC91231 ok
	printk (KERN_INFO"Current setting is SINGLE ENDED BIDIRECTIONAL\n");

        /* ------------------------------------------------------------------------ */
        #else
        #error Please Configure Transceiver Mode
	#endif /* CONFIG_OTG_ZASEVB_.... */
        /* ------------------------------------------------------------------------ */
	

        TRACE_MSG0(TCD, "1. I2C setup");

	THROW_IF ((i2c = i2c_configure(ADAPTER_NAME, ISP1301_I2C_ADDR_HIGH)), error);

        TRACE_MSG0(TCD, "2. ISP1301 module setup");
//        isp1301_mod_init(&zasevb_isp1301_bh);

        TRACE_MSG0(TCD, "3. SET TCD OPS");
        THROW_UNLESS(zasevb_tcd_instance = otg_set_tcd_ops(&tcd_ops), error);

        TRACE_MSG0(TCD, "4. ISP1301 device setup");

	mxc_iomux_gpio_isp1301_set (hwmode);
	 

        #ifdef CONFIG_ARCH_MXC91131
        writel (0x00000051, PLL2_DP_HFSOP);
        writel (0x00000051, PLL2_DP_OP);
        #endif /* CONFIG_ARCH_MXC91131 */
			
        /* ------------------------------------------------------------------------ */
        TRACE_MSG0(TCD, "7. SET HWMODE");
        isp1301_configure(tx_mode, spd_susp_reg);        
        mxc_main_clock_on();
        //mxc_host_clock_on();
        //mxc_func_clock_on();
	mxc_set_transceiver_mode(newmode);

		
	
        /* Success!
         */
        TRACE_MSG0(TCD, "8. Success!");

        CATCH(error) {
                printk(KERN_INFO"%s: failed\n", __FUNCTION__);
                UNLESS (i2c) i2c_close();
//                UNLESS (gpio) gpio_free_irq (ZGPIO_PORT, ZGPIO_PIN, GPIO_HIGH_PRIO);
                return -EINVAL;
        }
        TRACE_MSG0(TCD, "MX2_MOD_TCD_INIT FINISHED");
        return 0;
}