diff options
author | Tom Rini <trini@konsulko.com> | 2015-05-26 10:38:01 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2015-05-26 10:38:01 -0400 |
commit | 9bea236b3402a262772b66d055ec6431cbd3ba87 (patch) | |
tree | 8347dda9cb6ec9ad0d1bb15040257e01f8f31fc0 /drivers | |
parent | d43e15421014c17b90c3e288e3eff18ad8aaf346 (diff) | |
parent | 1022b85cb0e143b4f3a8e6c7d9258d516920d464 (diff) | |
download | u-boot-imx-9bea236b3402a262772b66d055ec6431cbd3ba87.zip u-boot-imx-9bea236b3402a262772b66d055ec6431cbd3ba87.tar.gz u-boot-imx-9bea236b3402a262772b66d055ec6431cbd3ba87.tar.bz2 |
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/i2c/mxc_i2c.c | 46 | ||||
-rw-r--r-- | drivers/pwm/pwm-imx-util.c | 4 | ||||
-rw-r--r-- | drivers/pwm/pwm-imx.c | 12 | ||||
-rw-r--r-- | drivers/thermal/imx_thermal.c | 36 |
4 files changed, 60 insertions, 38 deletions
diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 81adf6f..b3c50aa 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -170,6 +170,9 @@ static int bus_i2c_set_bus_speed(struct mxc_i2c_bus *i2c_bus, int speed) u8 idx = i2c_clk_div[clk_idx][1]; int reg_shift = quirk ? VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT; + if (!base) + return -ENODEV; + /* Store divider value */ writeb(idx, base + (IFDR << reg_shift)); @@ -351,6 +354,10 @@ static int i2c_init_transfer(struct mxc_i2c_bus *i2c_bus, u8 chip, int ret; int reg_shift = i2c_bus->driver_data & I2C_QUIRK_FLAG ? VF610_I2C_REGSHIFT : IMX_I2C_REGSHIFT; + + if (!i2c_bus->base) + return -ENODEV; + for (retry = 0; retry < 3; retry++) { ret = i2c_init_transfer_(i2c_bus, chip, addr, alen); if (ret >= 0) @@ -503,35 +510,30 @@ static int bus_i2c_write(struct mxc_i2c_bus *i2c_bus, u8 chip, u32 addr, return ret; } +#if !defined(I2C2_BASE_ADDR) +#define I2C2_BASE_ADDR 0 +#endif + +#if !defined(I2C3_BASE_ADDR) +#define I2C3_BASE_ADDR 0 +#endif + +#if !defined(I2C4_BASE_ADDR) +#define I2C4_BASE_ADDR 0 +#endif + static struct mxc_i2c_bus mxc_i2c_buses[] = { -#if defined(CONFIG_MX25) - { 0, IMX_I2C_BASE }, - { 1, IMX_I2C2_BASE }, - { 2, IMX_I2C3_BASE }, -#elif defined(CONFIG_MX27) - { 0, IMX_I2C1_BASE }, - { 1, IMX_I2C2_BASE }, -#elif defined(CONFIG_MX31) || defined(CONFIG_MX35) || \ - defined(CONFIG_MX51) || defined(CONFIG_MX53) || \ - defined(CONFIG_MX6) - { 0, I2C1_BASE_ADDR }, - { 1, I2C2_BASE_ADDR }, - { 2, I2C3_BASE_ADDR }, -#elif defined(CONFIG_LS102XA) - { 0, I2C1_BASE_ADDR, I2C_QUIRK_FLAG }, - { 1, I2C2_BASE_ADDR, I2C_QUIRK_FLAG }, - { 2, I2C3_BASE_ADDR, I2C_QUIRK_FLAG }, -#elif defined(CONFIG_VF610) - { 0, I2C0_BASE_ADDR, I2C_QUIRK_FLAG }, -#elif defined(CONFIG_FSL_LSCH3) +#if defined(CONFIG_LS102XA) || defined(CONFIG_FSL_LSCH3) { 0, I2C1_BASE_ADDR, I2C_QUIRK_FLAG }, { 1, I2C2_BASE_ADDR, I2C_QUIRK_FLAG }, { 2, I2C3_BASE_ADDR, I2C_QUIRK_FLAG }, { 3, I2C4_BASE_ADDR, I2C_QUIRK_FLAG }, #else -#error "architecture not supported" + { 0, I2C1_BASE_ADDR, 0 }, + { 1, I2C2_BASE_ADDR, 0 }, + { 2, I2C3_BASE_ADDR, 0 }, + { 3, I2C4_BASE_ADDR, 0 }, #endif - { } }; struct mxc_i2c_bus *i2c_get_base(struct i2c_adapter *adap) diff --git a/drivers/pwm/pwm-imx-util.c b/drivers/pwm/pwm-imx-util.c index 79d86028..f92c370 100644 --- a/drivers/pwm/pwm-imx-util.c +++ b/drivers/pwm/pwm-imx-util.c @@ -21,16 +21,12 @@ struct pwm_regs *pwm_id_to_reg(int pwm_id) switch (pwm_id) { case 0: return (struct pwm_regs *)PWM1_BASE_ADDR; - break; case 1: return (struct pwm_regs *)PWM2_BASE_ADDR; - break; case 2: return (struct pwm_regs *)PWM3_BASE_ADDR; - break; case 3: return (struct pwm_regs *)PWM4_BASE_ADDR; - break; default: printf("unknown pwm_id: %d\n", pwm_id); break; diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c index 40bf027..47799fc 100644 --- a/drivers/pwm/pwm-imx.c +++ b/drivers/pwm/pwm-imx.c @@ -18,6 +18,9 @@ int pwm_init(int pwm_id, int div, int invert) { struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); + if (!pwm) + return -1; + writel(0, &pwm->ir); return 0; } @@ -28,6 +31,9 @@ int pwm_config(int pwm_id, int duty_ns, int period_ns) unsigned long period_cycles, duty_cycles, prescale; u32 cr; + if (!pwm) + return -1; + pwm_imx_get_parms(period_ns, duty_ns, &period_cycles, &duty_cycles, &prescale); @@ -47,6 +53,9 @@ int pwm_enable(int pwm_id) { struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); + if (!pwm) + return -1; + setbits_le32(&pwm->cr, PWMCR_EN); return 0; } @@ -55,5 +64,8 @@ void pwm_disable(int pwm_id) { struct pwm_regs *pwm = (struct pwm_regs *)pwm_id_to_reg(pwm_id); + if (!pwm) + return; + clrbits_le32(&pwm->cr, PWMCR_EN); } diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 0bd9cfd..0d893c9 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -12,15 +12,15 @@ #include <fuse.h> #include <asm/io.h> #include <asm/arch/clock.h> +#include <asm/arch/sys_proto.h> #include <dm.h> #include <errno.h> #include <malloc.h> #include <thermal.h> #include <imx_thermal.h> -#define TEMPERATURE_MIN -40 -#define TEMPERATURE_HOT 80 -#define TEMPERATURE_MAX 125 +/* board will busyloop until this many degrees C below CPU max temperature */ +#define TEMPERATURE_HOT_DELTA 5 /* CPU maxT - 5C */ #define FACTOR0 10000000 #define FACTOR1 15976 #define FACTOR2 4297157 @@ -34,14 +34,21 @@ #define MISC0_REFTOP_SELBIASOFF (1 << 3) #define TEMPSENSE1_MEASURE_FREQ 0xffff +struct thermal_data { + unsigned int fuse; + int critical; + int minc; + int maxc; +}; + static int read_cpu_temperature(struct udevice *dev) { int temperature; unsigned int reg, n_meas; const struct imx_thermal_plat *pdata = dev_get_platdata(dev); struct anatop_regs *anatop = (struct anatop_regs *)pdata->regs; - unsigned int *priv = dev_get_priv(dev); - u32 fuse = *priv; + struct thermal_data *priv = dev_get_priv(dev); + u32 fuse = priv->fuse; int t1, n1; u32 c1, c2; u64 temp64; @@ -119,13 +126,15 @@ static int read_cpu_temperature(struct udevice *dev) int imx_thermal_get_temp(struct udevice *dev, int *temp) { + struct thermal_data *priv = dev_get_priv(dev); int cpu_tmp = 0; cpu_tmp = read_cpu_temperature(dev); - while (cpu_tmp > TEMPERATURE_MIN && cpu_tmp < TEMPERATURE_MAX) { - if (cpu_tmp >= TEMPERATURE_HOT) { - printf("CPU Temperature is %d C, too hot to boot, waiting...\n", - cpu_tmp); + while (cpu_tmp > priv->minc && cpu_tmp < priv->maxc) { + if (cpu_tmp >= priv->critical) { + printf("CPU Temperature (%dC) too close to max (%dC)", + cpu_tmp, priv->maxc); + puts(" waiting...\n"); udelay(5000000); cpu_tmp = read_cpu_temperature(dev); } else { @@ -147,7 +156,7 @@ static int imx_thermal_probe(struct udevice *dev) unsigned int fuse = ~0; const struct imx_thermal_plat *pdata = dev_get_platdata(dev); - unsigned int *priv = dev_get_priv(dev); + struct thermal_data *priv = dev_get_priv(dev); /* Read Temperature calibration data fuse */ fuse_read(pdata->fuse_bank, pdata->fuse_word, &fuse); @@ -158,7 +167,10 @@ static int imx_thermal_probe(struct udevice *dev) return -EPERM; } - *priv = fuse; + /* set critical cooling temp */ + get_cpu_temp_grade(&priv->minc, &priv->maxc); + priv->critical = priv->maxc - TEMPERATURE_HOT_DELTA; + priv->fuse = fuse; enable_thermal_clk(); @@ -170,6 +182,6 @@ U_BOOT_DRIVER(imx_thermal) = { .id = UCLASS_THERMAL, .ops = &imx_thermal_ops, .probe = imx_thermal_probe, - .priv_auto_alloc_size = sizeof(unsigned int), + .priv_auto_alloc_size = sizeof(struct thermal_data), .flags = DM_FLAG_PRE_RELOC, }; |