示例#1
0
int __init mx51_efikamx_init_pmic(void)
{
	CONFIG_IOMUX(mx51_efikamx_pmic_iomux_pins);

	/* disable power gating for some reason */
	if (machine_is_mx51_efikasb())
		pmic_write_reg(REG_POWER_MISC, ~(PWGT1SPIEN|PWGT2SPIEN), (PWGT1SPIEN|PWGT2SPIEN));

	if (machine_is_mx51_efikamx() && (mx51_efikamx_revision() == 1)) {
		CONFIG_IOMUX(mx51_efikamx_watchdog_pins);

		gpio_free(IOMUX_TO_GPIO(EFIKAMX_WATCHDOG_REBOOT));
		gpio_request(IOMUX_TO_GPIO(EFIKAMX_WATCHDOG_REBOOT), "sys:reboot");
		gpio_direction_output(IOMUX_TO_GPIO(EFIKAMX_WATCHDOG_REBOOT), 1);
	} else {
		CONFIG_IOMUX(mx51_efikasb_watchdog_pins);

		gpio_free(IOMUX_TO_GPIO(EFIKASB_WATCHDOG_REBOOT));
		gpio_request(IOMUX_TO_GPIO(EFIKASB_WATCHDOG_REBOOT), "sys:reboot");
		gpio_direction_output(IOMUX_TO_GPIO(EFIKASB_WATCHDOG_REBOOT), 1);

		if (machine_is_mx51_efikasb()) {
			CONFIG_IOMUX(mx51_efikasb_power_pins);

			gpio_free(IOMUX_TO_GPIO(EFIKASB_POWERGOOD));
			gpio_request(IOMUX_TO_GPIO(EFIKASB_POWERGOOD), "sys:powergood");
			gpio_direction_input(IOMUX_TO_GPIO(EFIKASB_POWERGOOD));
		}
	}

	return spi_register_board_info(mc13892_spi_device, ARRAY_SIZE(mc13892_spi_device));
}
示例#2
0
static void __init mx51_efikamx_board_init(void)
{
	mxc_cpu_common_init();
	mxc_register_gpios();

	CONFIG_IOMUX(mx51_efikamx_general_iomux_pins);

	/* do ID pins first! */
	if (machine_is_mx51_efikamx()) {
		CONFIG_IOMUX(mx51_efikamx_id_iomux_pins);
	} else if (machine_is_mx51_efikasb()) {
		CONFIG_IOMUX(mx51_efikasb_id_iomux_pins);
		CONFIG_IOMUX(mx51_efikasb_general_iomux_pins);
	}

	/* common platform configuration for all boards */
	mx51_efikamx_init_uart();
	mx51_efikamx_init_soc();
	mx51_efikamx_init_nor();
	mx51_efikamx_init_spi();
	mx51_efikamx_init_i2c();
	mx51_efikamx_init_pata();

	/* we do board id late because it takes time to settle */
	mx51_efikamx_board_id();

	/* these all depend on board id */
	mx51_efikamx_init_display();
	mx51_efikamx_init_audio();
	mx51_efikamx_init_pmic();
	mx51_efikamx_init_mmc();
	mx51_efikamx_init_leds();
	mx51_efikamx_init_periph();
	mx51_efikamx_init_usb();

	pm_power_off = mx51_efikamx_power_off;

	if (machine_is_mx51_efikamx()) {
		mxc_free_iomux(MX51_PIN_GPIO1_2, IOMUX_CONFIG_ALT2);
		mxc_free_iomux(MX51_PIN_GPIO1_3, IOMUX_CONFIG_ALT2);
		mxc_free_iomux(MX51_PIN_EIM_LBA, IOMUX_CONFIG_GPIO);

		DBG(("Smarttop Revision 1.%u", mx51_efikamx_revision() ));
	} else if (machine_is_mx51_efikasb()) {
		mx51_efikamx_init_battery();

		/* dastardly code to give us 1.3 or 2.0 out of "1" or "2" */
		DBG(("Smartbook Revision %u.%u\n",
					mx51_efikamx_revision(),
					((mx51_efikamx_revision() == 1) ? 3 : 0)  ));
		DBG(("Memory type %s\n", mx51_efikamx_memory() ));
	}
}
示例#3
0
void __init efika_board_common_init(void)
{
	mxc_iomux_v3_setup_multiple_pads(mx51efika_pads,
					ARRAY_SIZE(mx51efika_pads));
	imx51_add_imx_uart(0, &uart_pdata);
	mx51_efika_usb();
	imx51_add_sdhci_esdhc_imx(0, NULL);

	/* FIXME: comes from original code. check this. */
	if (mx51_revision() < IMX_CHIP_REVISION_2_0)
		sw2_init.constraints.state_mem.uV = 1100000;
	else if (mx51_revision() == IMX_CHIP_REVISION_2_0) {
		sw2_init.constraints.state_mem.uV = 1250000;
		sw1_init.constraints.state_mem.uV = 1000000;
	}
	if (machine_is_mx51_efikasb())
		vgen1_init.constraints.max_uV = 1200000;

	gpio_request(EFIKAMX_PMIC, "pmic irq");
	gpio_direction_input(EFIKAMX_PMIC);
	spi_register_board_info(mx51_efika_spi_board_info,
		ARRAY_SIZE(mx51_efika_spi_board_info));
	imx51_add_ecspi(0, &mx51_efika_spi_pdata);

#if defined(CONFIG_CPU_FREQ_IMX)
	get_cpu_op = mx51_get_cpu_op;
#endif
}
示例#4
0
int mx51_efikamx_revision(void)
{
	if (machine_is_mx51_efikamx()) {
		return(mx51_efikamx_id & 0xf);
	} else if (machine_is_mx51_efikasb()) {
		return(mx51_efikamx_id);
	}
	return 0;
}
示例#5
0
void __init mx51_efikamx_init_usb(void)
{
	CONFIG_IOMUX(mx51_efikamx_usb_iomux_pins);
	CONFIG_IOMUX(mx51_efikamx_usb_control_iomux_pins);

	if (machine_is_mx51_efikasb()) {
		CONFIG_IOMUX(mx51_efikasb_usb_iomux_pins);
	}

	gpio_request(IOMUX_TO_GPIO(EFIKAMX_USB_HUB_RESET), "usb:hub_reset");
	gpio_direction_output(IOMUX_TO_GPIO(EFIKAMX_USB_HUB_RESET), 1);

	gpio_request(IOMUX_TO_GPIO(EFIKAMX_USB_PHY_RESET), "usb:phy_reset");
	gpio_direction_output(IOMUX_TO_GPIO(EFIKAMX_USB_PHY_RESET), 1);

	mx51_efikamx_usb_hub_reset();

	mx51_efikamx_bluetooth_power(POWER_ON);
	mx51_efikamx_wifi_power(POWER_ON);
	mx51_efikamx_wifi_reset();

	if (machine_is_mx51_efikasb()) {
		mx51_efikamx_wwan_power(POWER_ON);
		mx51_efikamx_camera_power(POWER_ON);
	}

	mx51_efikamx_usb_phy_reset();

	mx5_usb_dr_init();
	mx5_usbh1_init();

	if (machine_is_mx51_efikasb()) {
		mx51_usbh2_init();
	}

	mx51_efikamx_usb_hub_enable();
}
static int __init mx51_efikasb_power_init(void)
{
	if (machine_is_mx51_efikasb()) {
		pwgt1 = regulator_get(NULL, "pwgt1");
		pwgt2 = regulator_get(NULL, "pwgt2");
		if (!IS_ERR(pwgt1) && !IS_ERR(pwgt2)) {
			regulator_enable(pwgt1);
			regulator_enable(pwgt2);
		}
		gpio_request(EFIKASB_POWEROFF, "poweroff");
		pm_power_off = mx51_efikasb_power_off;

		regulator_has_full_constraints();
	}

	return 0;
}
示例#7
0
static int ehci_mxc_drv_probe(struct platform_device *pdev)
{
	struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
	struct usb_hcd *hcd;
	struct resource *res;
	int irq, ret;
	unsigned int flags;
	struct ehci_mxc_priv *priv;
	struct device *dev = &pdev->dev;
	struct ehci_hcd *ehci;

	dev_info(&pdev->dev, "initializing i.MX USB Controller\n");

	if (!pdata) {
		dev_err(dev, "No platform data given, bailing out.\n");
		return -EINVAL;
	}

	irq = platform_get_irq(pdev, 0);

	hcd = usb_create_hcd(&ehci_mxc_hc_driver, dev, dev_name(dev));
	if (!hcd)
		return -ENOMEM;

	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
	if (!priv) {
		ret = -ENOMEM;
		goto err_alloc;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		dev_err(dev, "Found HC with no register addr. Check setup!\n");
		ret = -ENODEV;
		goto err_get_resource;
	}

	hcd->rsrc_start = res->start;
	hcd->rsrc_len = resource_size(res);

	if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
		dev_dbg(dev, "controller already in use\n");
		ret = -EBUSY;
		goto err_request_mem;
	}

	hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
	if (!hcd->regs) {
		dev_err(dev, "error mapping memory\n");
		ret = -EFAULT;
		goto err_ioremap;
	}

	/* enable clocks */
	priv->usbclk = clk_get(dev, "usb");
	if (IS_ERR(priv->usbclk)) {
		ret = PTR_ERR(priv->usbclk);
		goto err_clk;
	}
	clk_enable(priv->usbclk);

	if (!cpu_is_mx35() && !cpu_is_mx25()) {
		priv->ahbclk = clk_get(dev, "usb_ahb");
		if (IS_ERR(priv->ahbclk)) {
			ret = PTR_ERR(priv->ahbclk);
			goto err_clk_ahb;
		}
		clk_enable(priv->ahbclk);
	}

	/* "dr" device has its own clock on i.MX51 */
	if (cpu_is_mx51() && (pdev->id == 0)) {
		priv->phy1clk = clk_get(dev, "usb_phy1");
		if (IS_ERR(priv->phy1clk)) {
			ret = PTR_ERR(priv->phy1clk);
			goto err_clk_phy;
		}
		clk_enable(priv->phy1clk);
	}


	/* call platform specific init function */
	if (pdata->init) {
		ret = pdata->init(pdev);
		if (ret) {
			dev_err(dev, "platform init failed\n");
			goto err_init;
		}
		/* platforms need some time to settle changed IO settings */
		mdelay(10);
	}

	ehci = hcd_to_ehci(hcd);

	/* EHCI registers start at offset 0x100 */
	ehci->caps = hcd->regs + 0x100;
	ehci->regs = hcd->regs + 0x100 +
		HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));

	/* set up the PORTSCx register */
	ehci_writel(ehci, pdata->portsc, &ehci->regs->port_status[0]);

	/* is this really needed? */
	msleep(10);

	/* Initialize the transceiver */
	if (pdata->otg) {
		pdata->otg->io_priv = hcd->regs + ULPI_VIEWPORT_OFFSET;
		ret = otg_init(pdata->otg);
		if (ret) {
			dev_err(dev, "unable to init transceiver, probably missing\n");
			ret = -ENODEV;
			goto err_add;
		}
		ret = otg_set_vbus(pdata->otg, 1);
		if (ret) {
			dev_err(dev, "unable to enable vbus on transceiver\n");
			goto err_add;
		}
	}

	priv->hcd = hcd;
	platform_set_drvdata(pdev, priv);

	ret = usb_add_hcd(hcd, irq, IRQF_DISABLED | IRQF_SHARED);
	if (ret)
		goto err_add;

	if (pdata->otg) {
		/*
		 * efikamx and efikasb have some hardware bug which is
		 * preventing usb to work unless CHRGVBUS is set.
		 * It's in violation of USB specs
		 */
		if (machine_is_mx51_efikamx() || machine_is_mx51_efikasb()) {
			flags = otg_io_read(pdata->otg, ULPI_OTG_CTRL);
			flags |= ULPI_OTG_CTRL_CHRGVBUS;
			ret = otg_io_write(pdata->otg, flags, ULPI_OTG_CTRL);
			if (ret) {
				dev_err(dev, "unable to set CHRVBUS\n");
				goto err_add;
			}
		}
	}

	return 0;

err_add:
	if (pdata && pdata->exit)
		pdata->exit(pdev);
err_init:
	if (priv->phy1clk) {
		clk_disable(priv->phy1clk);
		clk_put(priv->phy1clk);
	}
err_clk_phy:
	if (priv->ahbclk) {
		clk_disable(priv->ahbclk);
		clk_put(priv->ahbclk);
	}
err_clk_ahb:
	clk_disable(priv->usbclk);
	clk_put(priv->usbclk);
err_clk:
	iounmap(hcd->regs);
err_ioremap:
	release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
err_request_mem:
err_get_resource:
	kfree(priv);
err_alloc:
	usb_put_hcd(hcd);
	return ret;
}
示例#8
0
void mx51_efikamx_board_id(void)
{
	if (machine_is_mx51_efikamx()) {
		int pcbid[3];

		mx51_efikamx_id = 0x10; /* can't get less than 1.0 */

		/* NOTE:
			IOMUX settings have to settle so run the iomux setup long before this
			function has to otherwise it will give freakish results.
		*/
		gpio_request(IOMUX_TO_GPIO(EFIKAMX_PCBID0), "efikamx:pcbid0");
		gpio_direction_input(IOMUX_TO_GPIO(EFIKAMX_PCBID0));
		pcbid[0] = gpio_get_value(IOMUX_TO_GPIO(EFIKAMX_PCBID0));

		gpio_request(IOMUX_TO_GPIO(EFIKAMX_PCBID1), "efikamx:pcbid1");
		gpio_direction_input(IOMUX_TO_GPIO(EFIKAMX_PCBID1));
		pcbid[1] = gpio_get_value(IOMUX_TO_GPIO(EFIKAMX_PCBID1));

		gpio_request(IOMUX_TO_GPIO(EFIKAMX_PCBID2), "efikamx:pcbid2");
		gpio_direction_input(IOMUX_TO_GPIO(EFIKAMX_PCBID2));
		pcbid[2] = gpio_get_value(IOMUX_TO_GPIO(EFIKAMX_PCBID2));

		/*
		 *	PCBID2 PCBID1 PCBID0  STATE
		 *	  1       1      1    ER1:rev1.1
		 *	  1       1      0    ER2:rev1.2
		 *	  1       0      1    ER3:rev1.3
		 *	  1       0      0    ER4:rev1.4
		 */
		if (pcbid[2] == 1) {
			if (pcbid[1] == 1) {
				if (pcbid[0] == 1) {
					mx51_efikamx_id = 0x11;
				} else {
					mx51_efikamx_id = 0x12;
				}
			} else {
				if (pcbid[0] == 1) {
					mx51_efikamx_id = 0x13;
				} else {
					mx51_efikamx_id = 0x14;
				}
			}
		}

		if ( (mx51_efikamx_id == 0x10) ||		/* "developer edition" */
			 (mx51_efikamx_id == 0x12) ||		/* unreleased, broken PATA */
			 (mx51_efikamx_id == 0x14) ) {		/* unreleased.. */
			DBG(("PCB Identification Error!\n"));
			DBG(("Unsupported board revision 1.%u - USE AT YOUR OWN RISK!\n",
					mx51_efikamx_revision() ));
		}
	} else if (machine_is_mx51_efikasb()) {
		int pcbid[2], memid[2];

		gpio_request(IOMUX_TO_GPIO(EFIKASB_MEMID0), "efikasb:memid0");
		gpio_direction_input(IOMUX_TO_GPIO(EFIKASB_MEMID0));
		memid[0] = gpio_get_value(IOMUX_TO_GPIO(EFIKASB_MEMID0));

		gpio_request(IOMUX_TO_GPIO(EFIKASB_MEMID1), "efikasb:memid1");
		gpio_direction_input(IOMUX_TO_GPIO(EFIKASB_MEMID1));
		memid[1] = gpio_get_value(IOMUX_TO_GPIO(EFIKASB_MEMID1));

	        gpio_request(IOMUX_TO_GPIO(EFIKASB_PCBID0), "efikasb:pcbid0");
        	gpio_direction_input(IOMUX_TO_GPIO(EFIKASB_PCBID0));
		pcbid[0] = gpio_get_value(IOMUX_TO_GPIO(EFIKASB_PCBID0));

	        gpio_request(IOMUX_TO_GPIO(EFIKASB_PCBID1), "efikasb:pcbid1");
        	gpio_direction_input(IOMUX_TO_GPIO(EFIKASB_PCBID1));
		pcbid[1] = gpio_get_value(IOMUX_TO_GPIO(EFIKASB_PCBID1));

		/*
		 *	PCBID1 PCBID0  STATE
		 *	  0	1	TO2: Revision 1.3
		 *	  1	0	TO3: Revision 2.0
		 */

		/* gives us 0x1 or 0x2 */
		mx51_efikamx_id = pcbid[0] | (pcbid[1] << 1);
		mx51_efikamx_mem = memid[0] | (memid[1] << 1);
	}
}
void __init mx51_efikamx_init_battery(void)
{
	if (machine_is_mx51_efikasb()) {
		i2c_register_board_info(1, &mx51_efikamx_i2c_battery, 1);
	}
}