3476f1159feadc70ca214bb72af914143ef15153
[platform/kernel/u-boot.git] / board / nvidia / whistler / whistler.c
1 /*
2  *  (C) Copyright 2010-2012
3  *  NVIDIA Corporation <www.nvidia.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <common.h>
9 #include <dm.h>
10 #include <asm/io.h>
11 #include <asm/arch/tegra.h>
12 #include <asm/arch/clock.h>
13 #include <asm/arch/funcmux.h>
14 #include <asm/arch/pinmux.h>
15 #include <asm/gpio.h>
16 #include <i2c.h>
17
18 #ifdef CONFIG_TEGRA_MMC
19 /*
20  * Routine: pin_mux_mmc
21  * Description: setup the pin muxes/tristate values for the SDMMC(s)
22  */
23 void pin_mux_mmc(void)
24 {
25         struct udevice *dev;
26         uchar val;
27         int ret;
28
29         /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
30         ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev);
31         if (ret) {
32                 printf("%s: Cannot find MAX8907B I2C chip\n", __func__);
33                 return;
34         }
35         val = 0x29;
36         ret = dm_i2c_write(dev, 0x46, &val, 1);
37         if (ret)
38                 printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
39         val = 0x00;
40         ret = dm_i2c_write(dev, 0x45, &val, 1);
41         if (ret)
42                 printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
43         val = 0x1f;
44         ret = dm_i2c_write(dev, 0x44, &val, 1);
45         if (ret)
46                 printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
47
48         funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
49         funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
50 }
51 #endif
52
53 /* this is a weak define that we are overriding */
54 void pin_mux_usb(void)
55 {
56         struct udevice *dev;
57         uchar val;
58         int ret;
59
60         /*
61          * This is a hack. This should be represented in DT using the
62          * vbus-gpio property. However, U-Boot's DT support doesn't
63          * support any GPIO controller other than the Tegra's yet.
64          */
65
66         /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
67         ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev);
68         if (ret) {
69                 printf("%s: Cannot find TAC6416 I2C chip\n", __func__);
70                 return;
71         }
72         val = 0x03;
73         ret = dm_i2c_write(dev, 2, &val, 1);
74         if (ret)
75                 printf("i2c_write 0 0x20 2 failed: %d\n", ret);
76         val = 0xfc;
77         ret = dm_i2c_write(dev, 6, &val, 1);
78         if (ret)
79                 printf("i2c_write 0 0x20 6 failed: %d\n", ret);
80 }