static int panel_init(struct omap_display_data *ddata)
{
	pr_debug("panel_init [%s]\n", ddata->panel_name);

	GPIO_INIT_OUTPUT(display_gpio.lcd_pwon);
	GPIO_INIT_OUTPUT(display_gpio.lcd_rst);
	GPIO_INIT_OUTPUT(display_gpio.lcd_pci);
	GPIO_INIT_OUTPUT(display_gpio.disp_select);
	GPIO_INIT_OUTPUT(display_gpio.cpldreset);

#if !defined(CONFIG_FB_OMAP_BOOTLOADER_INIT)
	if (GPIO_EXISTS(display_gpio.lcd_pwon))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pwon), 0);
	if (GPIO_EXISTS(display_gpio.lcd_rst))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_rst), 0);
	if (GPIO_EXISTS(display_gpio.lcd_pci))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pci), 0);

	/* reset and enable the CPLD */
	if (GPIO_EXISTS(display_gpio.cpldreset))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.cpldreset), 0);
	mdelay(2);
	if (GPIO_EXISTS(display_gpio.cpldreset))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.cpldreset), 1);
#endif
	return 0;
}
int archos_enable_ehci( int enable )
{
	if (enable) {
		if ( GPIO_EXISTS( gio_5v_enable ) )
			gpio_set_value( GPIO_PIN( gio_5v_enable ), 1);
		
		if ( GPIO_EXISTS( gio_ehci_enable ) ) 
			gpio_set_value( GPIO_PIN( gio_ehci_enable ), 1);
	} else {
		if ( GPIO_EXISTS( gio_ehci_enable ) ) 
			gpio_set_value( GPIO_PIN( gio_ehci_enable ), 0);

		if ( GPIO_EXISTS( gio_5v_enable ) )
			gpio_set_value( GPIO_PIN( gio_5v_enable ), 0);
	}
	
	if ( GPIO_EXISTS( gio_hub_enable ) ) {
		msleep(300);	// fix me

		if ( enable )
			gpio_set_value( GPIO_PIN( gio_hub_enable ), 1);
		else
			gpio_set_value( GPIO_PIN( gio_hub_enable ), 0);
	}

	ehci_phy_enable = enable;
	
	return 0;
}
static int archos_ehci_suspend(struct platform_device *dev, pm_message_t pm)
{
	printk("%s\n", __FUNCTION__);
	if ( GPIO_EXISTS( gio_ehci_enable ) )
		gpio_set_value( GPIO_PIN(gio_ehci_enable), 0);
	if ( GPIO_EXISTS( gio_5v_enable ) )
		gpio_set_value( GPIO_PIN(gio_5v_enable), 0);
	return 0;
}
static int archos_ehci_resume(struct platform_device *dev)
{
	printk("%s\n", __FUNCTION__);
	if ( GPIO_EXISTS( gio_5v_enable ) )
		gpio_set_value( GPIO_PIN(gio_5v_enable), ehci_phy_enable);
	if ( GPIO_EXISTS( gio_ehci_enable ) )
		gpio_set_value( GPIO_PIN( gio_ehci_enable ), ehci_phy_enable);
	return 0;
}
Exemplo n.º 5
0
static void panel_disable(struct omap_dss_device *disp)
{
    pr_debug("panel_disable [%s]\n", disp->name);

    if (GPIO_EXISTS(display_gpio.lcd_rst))
        gpio_set_value( GPIO_PIN(display_gpio.lcd_rst), 0 );
    if (GPIO_EXISTS(display_gpio.lcd_pwon))
        gpio_set_value( GPIO_PIN(display_gpio.lcd_pwon), 0 );

    panel_state = 0;
}
static int panel_set_backlight_level(
		struct omap_display *disp, int level)
{
	int hw_level;

	pr_debug("panel_set_backlight_level [%s] %d\n", 
		disp != NULL ? disp->panel->name: "cpt_wvga_48", level);

	/* skip if panel is not on */
	if (panel_state == 0) {
		saved_bkl_level = level;
		return 0;
	}
	
	/* clamp the level */
	if (level < 0)
		level = 0;
	if (level > 255)
		level = 255;

	/* nothing to do if levels are equal */
	if (bkl_level == level)
		return 0;

	/* stop backlight? */
	if (level == 0) {
		if (GPIO_EXISTS(display_gpio.bkl_pwon))
			omap_set_gpio_dataout(GPIO_PIN(display_gpio.bkl_pwon), 0);
		omap_dm_timer_stop(bkl_pwm);
		omap_dm_timer_disable(bkl_pwm);
		bkl_level = 0;
		return 0;
	}

	/* start backlight? */
	if (bkl_level == 0) {
		omap_dm_timer_enable(bkl_pwm);
		omap_dm_timer_set_pwm(bkl_pwm, 0, 1, 2);
		omap_dm_timer_start(bkl_pwm);
		if (GPIO_EXISTS(display_gpio.bkl_pwon))
			omap_set_gpio_dataout(GPIO_PIN(display_gpio.bkl_pwon), 1);
	}

	/* set new level, g7 machines have inverted level */
	hw_level = level;
	if (!machine_is_archos_g6h())
		hw_level = 255 - level;
	pwm_set_speed(bkl_pwm, 10000, hw_level);
	bkl_level = level;
	return 0;
}
static void panel_disable(struct omap_display *disp)
{
	pr_debug("panel_disable [%s]\n", disp->panel->name);

	if (GPIO_EXISTS(display_gpio.lcd_rst))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_rst), 0 );
	if (GPIO_EXISTS(display_gpio.lcd_pci))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pci), 0 );
	if (GPIO_EXISTS(display_gpio.lcd_pwon))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pwon), 0 );

	saved_bkl_level = bkl_level;
	panel_set_backlight_level(disp, 0);
	panel_state = 0;
}
Exemplo n.º 8
0
static int panel_init(struct omap_dss_device *ddata)
{

    pr_debug("panel_init [%s]\n", ddata->name);

    archos_gpio_init_output(&display_gpio.lcd_pwon, "lcd_pwon");
    archos_gpio_init_output(&display_gpio.lcd_rst, "lcd_rst");

#if !defined(CONFIG_FB_OMAP_BOOTLOADER_INIT)
    if (GPIO_EXISTS(display_gpio.lcd_pwon))
        gpio_set_value( GPIO_PIN(display_gpio.lcd_pwon), 0);
    if (GPIO_EXISTS(display_gpio.lcd_rst))
        gpio_set_value( GPIO_PIN(display_gpio.lcd_rst), 0);
#endif
    return 0;
}
static void phy_disable( void )
{
	if (GPIO_EXISTS(gpio_phy_enable))
		omap_set_gpio_dataout(GPIO_PIN(gpio_phy_enable), 0);
	mdelay(1);
	clk_disable(phy_clk);
}
static void panel_disable_tv(struct omap_dss_device *display)
{
	pr_info("panel_disable_tv\n");

	if (GPIO_EXISTS(cvbs_on))
		gpio_set_value( GPIO_PIN(cvbs_on), 0 );

}
Exemplo n.º 11
0
void __init usb_musb_init(void)
{
#ifdef CONFIG_USB_MUSB_SOC
	const struct archos_usb_config *usb_cfg;
	usb_cfg = omap_get_config( ARCHOS_TAG_USB, struct archos_usb_config );
	if (usb_cfg == NULL) {
		printk(KERN_DEBUG "archos_usb_init: no board configuration found\n");
		return;
	}
	if ( hardware_rev >= usb_cfg->nrev ) {
		printk(KERN_DEBUG "archos_usb_init: hardware_rev (%i) >= nrev (%i)\n",
			hardware_rev, usb_cfg->nrev);
		return;
	}

	/* ground USB ID pin */
	gpio_usb_id = usb_cfg->rev[hardware_rev].usb_id;
	if (GPIO_EXISTS(gpio_usb_id)) {
		GPIO_INIT_OUTPUT( gpio_usb_id );
		omap_set_gpio_dataout( GPIO_PIN( gpio_usb_id ), 0 );
	}

	/* keep PHY in reset to save power... */	
	gpio_phy_enable = usb_cfg->rev[hardware_rev].enable_usb_musb;
	if (GPIO_EXISTS(gpio_phy_enable)) {
		GPIO_INIT_OUTPUT( gpio_phy_enable );
		omap_set_gpio_dataout( GPIO_PIN ( gpio_phy_enable ), 0);
	}

	/* sys_clkout1 is needed by the phy */
	phy_clk = clk_get(NULL, "sys_clkout1");
	if (IS_ERR(phy_clk)) {
		/* No need to proceed, PHY will not work without clock */
		pr_err("usb_musb_init: cannot get PHY external clock\n");
		return;
	}

	if (platform_device_register(&musb_device) < 0) {
		printk(KERN_ERR "Unable to register HS-USB (MUSB) device\n");
		return;
	}
	
	otg_set_transceiver(&musb_xceiv);
#endif
}
Exemplo n.º 12
0
static int panel_enable(struct omap_dss_device *disp)
{
    pr_debug("panel_enable [%s]\n", disp->name);

    if ( panel_state == 1 )
        return -1;

    if (GPIO_EXISTS(display_gpio.lcd_pwon)) {
        gpio_set_value( GPIO_PIN(display_gpio.lcd_pwon), 1 );
        msleep(50);
    }
    if (GPIO_EXISTS(display_gpio.lcd_rst)) {
        gpio_set_value( GPIO_PIN(display_gpio.lcd_rst), 1 );
        msleep(100);
    }
    panel_state = 1;
    return 0;
}
Exemplo n.º 13
0
static int panel_enable_tv(struct omap_dss_device *display)
{
	pr_info("panel_enable_tv\n");

	if (GPIO_EXISTS(cvbs_on)) {
		gpio_set_value( GPIO_PIN(cvbs_on), 1 );
		msleep(1);
	}
	return 0;
}
Exemplo n.º 14
0
int archos_set_usb_id( int enable )
{
	if (GPIO_EXISTS(gpio_usb_id)) {
		if (enable) 
			omap_set_gpio_dataout( GPIO_PIN( gpio_usb_id ), 1);
		else
			omap_set_gpio_dataout( GPIO_PIN( gpio_usb_id ), 0);
	}

	return 0;
} 
int archos_enable_ohci( int enable )
{
printk(" enable ohci interface %d \n", enable);
	if ( GPIO_EXISTS( gio_ohci_enable ) ) {
		if ( enable )
			gpio_set_value( GPIO_PIN( gio_ohci_enable ), 1);
		else
			gpio_set_value( GPIO_PIN( gio_ohci_enable ), 0);
	}

	return 0;
}
static int panel_enable(struct omap_display *disp)
{
	pr_info("panel_enable [%s]\n", disp->panel->name);

	if (GPIO_EXISTS(display_gpio.disp_select))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.disp_select), 1);

	if (GPIO_EXISTS(display_gpio.lcd_pwon)) {
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pwon), 1 );
		msleep(50);
	}
	if (GPIO_EXISTS(display_gpio.lcd_rst)) {
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_rst), 1 );
		msleep(100);
	}
	if (GPIO_EXISTS(display_gpio.lcd_pci))
		omap_set_gpio_dataout( GPIO_PIN(display_gpio.lcd_pci), 1 );

	panel_state = 1;
	panel_set_backlight_level(disp, saved_bkl_level);
	return 0;
}
Exemplo n.º 17
0
int archos_enable_ehci( int enable )
{
	if ( GPIO_EXISTS( gio_ehci_enable ) ) {
		if ( enable )
			omap_set_gpio_dataout( GPIO_PIN( gio_ehci_enable ), 1);
		else
			omap_set_gpio_dataout( GPIO_PIN( gio_ehci_enable ), 0);
	}

	ehci_phy_enable = enable;
	
	return 0;
}
static void panel_tv_init(void)
{
	if (hardware_rev >= display_config.nrev)
		return;

	pr_info("panel_tv_init\n");

	if (GPIO_EXISTS(display_config.rev[hardware_rev].cvbs_on)) {
		cvbs_on = display_config.rev[hardware_rev].cvbs_on;
		archos_gpio_init_output(&cvbs_on, "cvbs enable");
		gpio_set_value( GPIO_PIN(cvbs_on), 0 );
	}
}
void __init archos_usb_ohci_init(void)
{
#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)

	const struct archos_fsusb_config *usb_cfg;
	
	usb_cfg = omap_get_config( ARCHOS_TAG_FSUSB, struct archos_fsusb_config );
	if (usb_cfg == NULL) {
		printk(KERN_DEBUG "%s: no board configuration found\n", __FUNCTION__);
		return;
	}
	if ( hardware_rev >= usb_cfg->nrev ) {
		printk(KERN_DEBUG "%s: hardware_rev (%i) >= nrev (%i)\n",
			__FUNCTION__, hardware_rev, usb_cfg->nrev);
		return;
	}

	printk("archos_usb_ohci_init\n");

	if ( GPIO_EXISTS(usb_cfg->rev[hardware_rev].enable_usb_ohci)) {

		gio_ohci_enable = usb_cfg->rev[hardware_rev].enable_usb_ohci;

		archos_gpio_init_output( &gio_ohci_enable, "fsusb_enable" );

		archos_enable_ohci( 0 );

		gio_ohci_suspend = usb_cfg->rev[hardware_rev].suspend;
		archos_gpio_init_output( &gio_ohci_suspend, "fsusb_suspend" );
		gpio_set_value( GPIO_PIN(gio_ohci_suspend), 0);

		archos_enable_ohci( 1 );

	}

	omap_cfg_reg(AG8_3430_USB2FS_RCV);
	omap_cfg_reg(AH8_3430_USB2FS_VM);
	omap_cfg_reg(AB2_3430_USB2FS_VP);
	omap_cfg_reg(V3_3430_USB2FS_EN);

	if (platform_device_register(&ohci_device) < 0) {
		printk(KERN_ERR "Unable to register FS-USB (OHCI) device\n");
		return;
	}
	
	device_create_file(&ohci_device.dev, &dev_attr_fsusb_enable);
	device_create_file(&ohci_device.dev, &dev_attr_fsusb_suspend);
#endif
}
Exemplo n.º 20
0
static int __init archos_battery_probe(struct platform_device *pdev)
{
	int ret;
	const struct archos_charge_config *chg_cfg;
	
	bat = kzalloc(sizeof(struct archos_battery), GFP_KERNEL);
	if (bat == NULL)
		return -ENOMEM;
	
	bat->main_battery = main_battery_template;
	bat->ac_supply = ac_supply_template;
	bat->usb_supply = usb_supply_template;
	bat->charge_enable = UNUSED_GPIO;
	bat->charge_low = UNUSED_GPIO;
	bat->charge_high = UNUSED_GPIO;

	/* FIXME: default values for now */
	bat->current_mV = 3850;
	bat->current_capacity = 50;
	bat->voltage_max_design = 4200;
	bat->voltage_min_design = 3500;

	/* charger configuration */
	chg_cfg = omap_get_config( ARCHOS_TAG_CHARGE, struct archos_charge_config);
	if (chg_cfg != NULL && hardware_rev < chg_cfg->nrev) {
		if (GPIO_EXISTS(chg_cfg->rev[hardware_rev].charge_enable) &&
		    GPIO_EXISTS(chg_cfg->rev[hardware_rev].charge_low) &&
		    GPIO_EXISTS(chg_cfg->rev[hardware_rev].charge_high) ) {
			bat->charge_enable = chg_cfg->rev[hardware_rev].charge_enable;
			bat->charge_low = chg_cfg->rev[hardware_rev].charge_low;
			bat->charge_high = chg_cfg->rev[hardware_rev].charge_high;

			archos_gpio_init_output(&bat->charge_enable, "charge enable");
			archos_gpio_init_output(&bat->charge_low, "charge low");
			archos_gpio_init_output(&bat->charge_high, "charge high");

			ret = device_create_file(&pdev->dev, &dev_attr_charge_level);
			if (ret < 0)
				dev_dbg(&pdev->dev, "cannot create charge_level attribute\n");
		}
		
		if (chg_cfg->rev[hardware_rev].gpio_dc_detect) {
			int ret;
			
			bat->gpio_dc_detect = chg_cfg->rev[hardware_rev].gpio_dc_detect;
			gpio_request(bat->gpio_dc_detect, "dc detect");
			gpio_direction_input(bat->gpio_dc_detect);
			
			bat->old_dcin = gpio_get_value_cansleep(bat->gpio_dc_detect);

			ret = request_irq(gpio_to_irq(bat->gpio_dc_detect), dcin_irq_handler, 
					IRQF_TRIGGER_FALLING|IRQF_TRIGGER_RISING, 
					"dc detect", pdev);
			if (ret < 0)
				dev_warn(&pdev->dev, "failed to request irq %i for dc detect\n", 
						gpio_to_irq(bat->gpio_dc_detect));
		}
	}
	
	platform_set_drvdata(pdev, bat);
	
	ret = power_supply_register(&pdev->dev, &bat->main_battery);
	if (ret < 0) {
		printk(KERN_DEBUG "archos_battery_probe: "
				"cannot register main battery: %i\n", ret);
	}
	ret = power_supply_register(&pdev->dev, &bat->ac_supply);
	if (ret < 0) {
		printk(KERN_DEBUG "archos_battery_probe: "
				"cannot register ac supply: %i\n", ret);
	}
	ret = power_supply_register(&pdev->dev, &bat->usb_supply);
	if (ret < 0) {
		printk(KERN_DEBUG "archos_battery_probe: "
				"cannot register usb supply: %i\n", ret);
	}

	ret = device_create_file(&pdev->dev, &dev_attr_voltage_avg);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create voltage_avg attribute\n");
	ret = device_create_file(&pdev->dev, &dev_attr_capacity);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create capacity attribute\n");
	ret = device_create_file(&pdev->dev, &dev_attr_ac_online);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create ac_online attribute\n");
	ret = device_create_file(&pdev->dev, &dev_attr_usb_online);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create usb_online attribute\n");
	ret = device_create_file(&pdev->dev, &dev_attr_voltage_max_design);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create voltage_max_design attribute\n");
	ret = device_create_file(&pdev->dev, &dev_attr_voltage_min_design);
	if (ret < 0)
		dev_dbg(&pdev->dev, "cannot create voltage_min_design attribute\n");
	return 0;	
}
Exemplo n.º 21
0
static int main_battery_get_property(struct power_supply *psy,
		enum power_supply_property psp,
		union power_supply_propval *val)
{
	struct archos_battery *bat = container_of(psy, struct archos_battery, main_battery);
	
	switch (psp) {
	case POWER_SUPPLY_PROP_STATUS:
		if (!get_on_dcin(bat) && !bat->on_usb) {
			val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
			break;
		}
		if (bat->charge_state)
			val->intval = POWER_SUPPLY_STATUS_CHARGING;
		else
			val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
		break;
		
	case POWER_SUPPLY_PROP_PRESENT:
		val->intval = 1; /* always present */
		break;
	
	case POWER_SUPPLY_PROP_CAPACITY:
		val->intval = bat->current_capacity;
		break;
		
	case POWER_SUPPLY_PROP_VOLTAGE_NOW:
		val->intval = bat->current_mV;
		break;
		
	case POWER_SUPPLY_PROP_VOLTAGE_AVG:
		val->intval = bat->current_mV;
		break;

	case POWER_SUPPLY_PROP_HEALTH:
		val->intval = POWER_SUPPLY_HEALTH_UNKNOWN;
		break;

	case POWER_SUPPLY_PROP_TEMP:
		val->intval = 230; /* we have no sensor for that */
		break;
		
	case POWER_SUPPLY_PROP_TECHNOLOGY:
		val->intval = POWER_SUPPLY_TECHNOLOGY_LIPO;
		break;
		
	case POWER_SUPPLY_PROP_VOLTAGE_MAX_DESIGN:
		val->intval = bat->voltage_max_design;
		break;
		
	case POWER_SUPPLY_PROP_VOLTAGE_MIN_DESIGN:
		val->intval = bat->voltage_min_design;
		break;
		
	case POWER_SUPPLY_PROP_CHARGE_NOW:
		if (!GPIO_EXISTS(bat->charge_enable)) {
			if (bat->charge_state)
				val->intval = 1000;
			else
				val->intval = 0;
			break;
		}
		
		switch(bat->charge_level) {
		case 1:
			val->intval = 100;
			break;
		case 2:
			val->intval = 500;
			break;
		case 3:
			val->intval = 1000;
			break;
		case 0:
		default:
			val->intval = 0;
			break;
		}
		break;
		
	default:
		return -EINVAL;
	}
	
	return 0;
}
Exemplo n.º 22
0
int __init archos_wifi_init(void)
{
	int ret;
	const struct archos_wifi_bt_config *wifi_bt_cfg;
	struct archos_gpio wifi_irq;
	struct archos_gpio bt_nshutdown;
	
	wifi_bt_cfg = omap_get_config(ARCHOS_TAG_WIFI_BT, struct archos_wifi_bt_config);
	
	/* might be NULL */
	if (wifi_bt_cfg == NULL) {
		printk(KERN_DEBUG "archos_wifi_init: no board configuration found\n");
		return -ENODEV;
	}
	if ( hardware_rev >= wifi_bt_cfg->nrev ) {
		printk(KERN_DEBUG "archos_wifi_init: hardware_rev (%i) >= nrev (%i)\n",
			hardware_rev, wifi_bt_cfg->nrev);
		return -ENODEV;
	}

	wifi_irq = wifi_bt_cfg->rev[hardware_rev].wifi_irq;
	wifi_pmena = wifi_bt_cfg->rev[hardware_rev].wifi_power;
	archos_wifi_pa_type = wifi_bt_cfg->rev[hardware_rev].wifi_pa_type;

	printk("%s: start\n", __func__);
	ret = gpio_request(GPIO_PIN(wifi_irq), "wifi_irq");
	if (ret < 0) {
		printk(KERN_ERR "%s: can't reserve GPIO: %d\n", __func__,
			GPIO_PIN(wifi_irq));
		goto out;
	}
	gpio_direction_input(GPIO_PIN(wifi_irq));

	archos_wlan_data.irq = gpio_to_irq(GPIO_PIN(wifi_irq));
	if (wl12xx_set_platform_data(&archos_wlan_data)) {
		pr_err("archos_wifi_bt_init: error setting wl12xx data\n");
		return -1;
	}

	bt_nshutdown = wifi_bt_cfg->rev[hardware_rev].bt_power;
	if (GPIO_EXISTS(bt_nshutdown)) {
		wl1271_chip_plat_data.nshutdown_gpio = GPIO_PIN(bt_nshutdown);
		ret = platform_device_register(&wl1271_chip_device);
		if (ret < 0)
			goto out;
	}

	ret = platform_device_register(&bt_device);
	if (ret < 0) {
		pr_err("archos_wifi_bt_init: couldn't register bt device\n");
		return -1;
	}

	ret = platform_device_register(&archos_wifi_device);
	if (ret < 0)
		goto out;
	
	ret = device_create_file(&archos_wifi_device.dev, &dev_attr_wifi_reset);
	if (ret < 0)
		goto out;

	ret = device_create_file(&archos_wifi_device.dev, &dev_attr_wifi_pa_type);

out:
        return ret;
}