From d8d160e4205aa2885cfe659102c9555ef0859fae Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 21 Nov 2014 17:54:42 +0100 Subject: mxs_ocotp: prevent error path from returning success The code may goto 'fail' upon error with 'ret' variable set to an error code, but this variable was being overwritten by a final preparation function to restore the HCLK, so success was (in general) returned even after an error was hit previously. With this change, the function may now return success even if the final preparation function fails, but it's probably enough to print a message because (if successful) the real programming of the fuses has already completed. Signed-off-by: Hector Palacios --- drivers/misc/mxs_ocotp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/mxs_ocotp.c b/drivers/misc/mxs_ocotp.c index 545d3eb..0900281 100644 --- a/drivers/misc/mxs_ocotp.c +++ b/drivers/misc/mxs_ocotp.c @@ -223,11 +223,8 @@ static int mxs_ocotp_write_fuse(uint32_t addr, uint32_t mask) fail: mxs_ocotp_scale_vddio(0, &vddio_val); - ret = mxs_ocotp_scale_hclk(0, &hclk_val); - if (ret) { + if (mxs_ocotp_scale_hclk(0, &hclk_val)) puts("Failed scaling up the HCLK!\n"); - return ret; - } return ret; } -- cgit v1.1 From ad5dd7ae4b0474b8e359c691cddb310940276695 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 21 Nov 2014 17:54:43 +0100 Subject: mxs_ocotp: check for errors from the OTP controller after writing The write operation may fail when trying to write to a locked area. In this case the ERROR bit is set in the CTRL register. Check for that condition and return an error. Signed-off-by: Hector Palacios Reviewed-by: Fabio Estevam --- drivers/misc/mxs_ocotp.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/mxs_ocotp.c b/drivers/misc/mxs_ocotp.c index 0900281..1659ee6 100644 --- a/drivers/misc/mxs_ocotp.c +++ b/drivers/misc/mxs_ocotp.c @@ -221,6 +221,13 @@ static int mxs_ocotp_write_fuse(uint32_t addr, uint32_t mask) goto fail; } + /* Check for errors */ + if (readl(&ocotp_regs->hw_ocotp_ctrl) & OCOTP_CTRL_ERROR) { + puts("Failed writing fuses!\n"); + ret = -EPERM; + goto fail; + } + fail: mxs_ocotp_scale_vddio(0, &vddio_val); if (mxs_ocotp_scale_hclk(0, &hclk_val)) -- cgit v1.1 From 3d99fcbc159915405a77e8bd5d719ba446137875 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Fri, 21 Nov 2014 17:54:44 +0100 Subject: mxs_ocotp: clear the error flag before initiating write operation A previous operation may have set the error flag, which must be cleared before a new write operation can be issued. Signed-off-by: Hector Palacios --- drivers/misc/mxs_ocotp.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers') diff --git a/drivers/misc/mxs_ocotp.c b/drivers/misc/mxs_ocotp.c index 1659ee6..6f0a1d3 100644 --- a/drivers/misc/mxs_ocotp.c +++ b/drivers/misc/mxs_ocotp.c @@ -187,6 +187,8 @@ static int mxs_ocotp_write_fuse(uint32_t addr, uint32_t mask) uint32_t hclk_val, vddio_val; int ret; + mxs_ocotp_clear_error(); + /* Make sure the banks are closed for reading. */ ret = mxs_ocotp_read_bank_open(0); if (ret) { -- cgit v1.1 From 7267c925b3817478c9ccd0c4a1286ff81f7859f9 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Mon, 24 Nov 2014 12:24:15 -0200 Subject: thermal: imx_thermal: Do not display calibration data Printing the calibration data on every boot does not provide really useful information: U-Boot 2015.01-rc1-18266-ge7eb277 (Nov 24 2014 - 11:29:51) CPU: Freescale i.MX6Q rev1.2 at 792 MHz CPU: Thermal calibration data: 0x5d85067d CPU: Temperature 33 C Reset cause: POR Board: MX6-SabreSD Do not display the calibration data in order to have a cleaner boot log. Signed-off-by: Fabio Estevam --- drivers/thermal/imx_thermal.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index 1161585..0bd9cfd 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c @@ -156,8 +156,6 @@ static int imx_thermal_probe(struct udevice *dev) if (fuse == 0 || fuse == ~0) { printf("CPU: Thermal invalid data, fuse: 0x%x\n", fuse); return -EPERM; - } else { - printf("CPU: Thermal calibration data: 0x%x\n", fuse); } *priv = fuse; -- cgit v1.1 From a847fff11cc4f3745d0087d45d2e5964c47f55d2 Mon Sep 17 00:00:00 2001 From: Fabio Estevam Date: Tue, 25 Nov 2014 13:11:08 -0200 Subject: mxc_ocotp: Do not disable the OCOTP clock after every access MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Leave the OCOTP turned on, so that we subsequent access do not fail. After enabling the thermal driver on a mx6sxsabresd board: U-Boot 2015.01-rc1-18267-g99d4189-dirty (Nov 24 2014 - 12:59:01) CPU: Freescale i.MX6SX rev1.0 at 792 MHz CPU: Temperature 48 C Reset cause: POR Board: MX6SX SABRE SDB I2C: ready DRAM: 1 GiB PMIC: PFUZE100 ID=0x10 MMC: FSL_SDHC: 0, FSL_SDHC: 1, FSL_SDHC: 2 00:01.0 - 16c3:abcd - Bridge device 01:00.0 - 8086:08b1 - Network controller In: serial Out: serial Err: serial Net: (hang) As the thermal driver accesses the ocotp registers, its clock will be disabled afterwards. Then when the MAC address is read (also from ocotp registers) it will cause a hang. Do not disable the ocotp clock to prevent this problem. Signed-off-by: Fabio Estevam Reviewed-by: Benoît Thébaudeau --- drivers/misc/mxc_ocotp.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers') diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c index 89737af..d92044e 100644 --- a/drivers/misc/mxc_ocotp.c +++ b/drivers/misc/mxc_ocotp.c @@ -81,8 +81,6 @@ static int finish_access(struct ocotp_regs *regs, const char *caller) err = !!(readl(®s->ctrl) & BM_CTRL_ERROR); clear_error(regs); - enable_ocotp_clk(0); - if (err) { printf("mxc_ocotp %s(): Access protect error\n", caller); return -EIO; -- cgit v1.1 From dd1c8f1b5fb63a682fce62a53464108d8587b0a2 Mon Sep 17 00:00:00 2001 From: Soeren Moch Date: Thu, 27 Nov 2014 10:11:41 +0100 Subject: sata: fix reset_sata for dwc_ahsata - fix crash when sata device is not initialized - remove disable_sata_clock() since it is not clear which clock for which device should be disabled here - call disable_sata_clock() for mx6 in preboot_os instead Signed-off-by: Soeren Moch Acked-by: Nikita Kiryanov Tested-by: Nikita Kiryanov --- drivers/block/dwc_ahsata.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers') diff --git a/drivers/block/dwc_ahsata.c b/drivers/block/dwc_ahsata.c index 9a2b547..01a4148 100644 --- a/drivers/block/dwc_ahsata.c +++ b/drivers/block/dwc_ahsata.c @@ -594,22 +594,24 @@ int init_sata(int dev) int reset_sata(int dev) { - struct ahci_probe_ent *probe_ent = - (struct ahci_probe_ent *)sata_dev_desc[dev].priv; - struct sata_host_regs *host_mmio = - (struct sata_host_regs *)probe_ent->mmio_base; + struct ahci_probe_ent *probe_ent; + struct sata_host_regs *host_mmio; if (dev < 0 || dev > (CONFIG_SYS_SATA_MAX_DEVICE - 1)) { printf("The sata index %d is out of ranges\n\r", dev); return -1; } + probe_ent = (struct ahci_probe_ent *)sata_dev_desc[dev].priv; + if (NULL == probe_ent) + /* not initialized, so nothing to reset */ + return 0; + + host_mmio = (struct sata_host_regs *)probe_ent->mmio_base; setbits_le32(&host_mmio->ghc, SATA_HOST_GHC_HR); while (readl(&host_mmio->ghc) & SATA_HOST_GHC_HR) udelay(100); - disable_sata_clock(); - return 0; } -- cgit v1.1