Re: [U-Boot-Users] [PATCH 07/10] [ARM] TQMA31: adjust voltage regulators in PMIC MC13738
Hi Jens, On Tue, Jul 8, 2008 at 10:55 AM, Jens Gehrlein [EMAIL PROTECTED] wrote: Hi Magnus, Magnus Lilja schrieb: Hi, Jens Gehrlein wrote: +static int adjust_voltages (void) +{ + u32 reg; + u32 val; + static struct spi_slave *slave = NULL; + + slave = spi_setup_slave(1, 0, 100, + SPI_MODE_2 | SPI_CS_HIGH); + if (!slave) + return -1; + + if (spi_claim_bus(slave)) + return -1; + + /* Set PMIC arbitration switchers */ + val = 0x20; + reg = 0x1400 | val | 0x8000; It seems like it's time to create a MC13783 header file containing some helper macros and symbolic names to the 13783's registers so we can write: reg = MC13783_READ_CMD(MC_REG_FOO); ... val = something_symbolic | something_symbolic2; reg = MC13783_WRITE_CMD(MC_REG_FOO, val); ... etc.. Also, I'm pretty sure some other i.MX31 boards could benefit from changing some voltages in U-boot so perhaps we could have a mc13783-reg.c (-reg as in regulators) file containing stuff like mc13783_set_regulator(MC_VRFDIG, VRFDIG_1V8)? Basically, I agree. But would you accept the current patch for now? The new routines and macros later could be implemented later. I don't think it's up to me to ACK or NAK this, but I can accept the current patch. Regards, Magnus Lilja - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ___ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
Re: [U-Boot-Users] [PATCH 07/10] [ARM] TQMA31: adjust voltage regulators in PMIC MC13738
On 18:11 Wed 09 Jul , Detlev Zundel wrote: Hi Magnus and Jens, Basically, I agree. But would you accept the current patch for now? The new routines and macros later could be implemented later. I don't think it's up to me to ACK or NAK this, but I can accept the current patch. Yes, this decision is up to the custodian. But lets be honest here, we all know what we can implement this later means. We really need to fix problems as they arise. Especially in this case I don't think that it is such a significant effort to fix it now. Fixing it later will only need even more effort. Usually this effort(t-[detection time]) is an exponential function and I am not kidding on this. I fully agree with you. We need to fix this and not use a workaround which will became the status quo. Best Regards, J. - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ___ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
Re: [U-Boot-Users] [PATCH 07/10] [ARM] TQMA31: adjust voltage regulators in PMIC MC13738
Hi Magnus, Magnus Lilja schrieb: Hi, Jens Gehrlein wrote: +static int adjust_voltages (void) +{ +u32 reg; +u32 val; +static struct spi_slave *slave = NULL; + +slave = spi_setup_slave(1, 0, 100, +SPI_MODE_2 | SPI_CS_HIGH); +if (!slave) +return -1; + +if (spi_claim_bus(slave)) +return -1; + +/* Set PMIC arbitration switchers */ +val = 0x20; +reg = 0x1400 | val | 0x8000; It seems like it's time to create a MC13783 header file containing some helper macros and symbolic names to the 13783's registers so we can write: reg = MC13783_READ_CMD(MC_REG_FOO); ... val = something_symbolic | something_symbolic2; reg = MC13783_WRITE_CMD(MC_REG_FOO, val); ... etc.. Also, I'm pretty sure some other i.MX31 boards could benefit from changing some voltages in U-boot so perhaps we could have a mc13783-reg.c (-reg as in regulators) file containing stuff like mc13783_set_regulator(MC_VRFDIG, VRFDIG_1V8)? Basically, I agree. But would you accept the current patch for now? The new routines and macros later could be implemented later. Kind regards, Jens - Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08 ___ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
[U-Boot-Users] [PATCH 07/10] [ARM] TQMA31: adjust voltage regulators in PMIC MC13738
VRFDIG: 1.875 V - 1.8 V VGEN: 1.5 V - 1.8 V VDIG: 1.5 V - 1.3 V Unused PMIC switchers and regulators are disabled Signed-off-by: Jens Gehrlein [EMAIL PROTECTED] --- board/tqc/tqma31/tqma31.c | 142 + include/configs/TQMA31.h |2 + 2 files changed, 144 insertions(+), 0 deletions(-) diff --git a/board/tqc/tqma31/tqma31.c b/board/tqc/tqma31/tqma31.c index c704c41..abb8db0 100644 --- a/board/tqc/tqma31/tqma31.c +++ b/board/tqc/tqma31/tqma31.c @@ -22,6 +22,7 @@ #include common.h #include asm/io.h +#include spi.h #include asm/arch/mx31.h #include asm/arch/mx31-regs.h @@ -70,6 +71,132 @@ static void setup_iomux (void) mx31_pad_ctl (PAD_CTL_CSPI2_MOSI, 0); } +static int adjust_voltages (void) +{ + u32 reg; + u32 val; + static struct spi_slave *slave = NULL; + + slave = spi_setup_slave(1, 0, 100, + SPI_MODE_2 | SPI_CS_HIGH); + if (!slave) + return -1; + + if (spi_claim_bus(slave)) + return -1; + + /* Set PMIC arbitration switchers */ + val = 0x20; + reg = 0x1400 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + /* Set PMIC regulator enable to 0x0 */ + val = 0x00; + reg = 0x2000 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + /* +* Set PMIC regulator setting 0 +* VRFDIG = 1,8V / reset value = 1,875V +* VGEN = 1,8V / reset value = 1,5V +* VDIG = 1,3V / reset value = 1,5V +*/ + val = 0x63cdc; + reg = 0x3c00 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + /* +* Set PMIC regulator mode 0 to 0x24924 +* VAUDIO = on +* VIOH= off +* VIOLO = on +* VDIG= on +* VGEN= on +* VRFDIG = on +* VRFREF = on +* VRFCP = on +*/ + val = 0x249241; + reg = 0x4000 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + /* +* Set PMIC regulator mode 1 to 0x0 +* VSIM= off +* VESIM = off +* VCAM= off +* VRFBG = off +* VVIB= off +* VRF1= off +* VRF2= off +* VMMC1 = off +* VMMC2 = off +*/ + val = 0x0; + reg = 0x4200 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + /* +* FIXME: switcher settings 0 and 1. +* Kernel hangs when unpacking itself. +* Workaround: +* Up to now CPU can operate at maximum allowed voltage 1.6 V. +*/ + /* +* Set PMIC switcher setting 0 +* SW1A = 1,2V / reset value = 1,6V +* SW1ADVS = 1,6V / reset value = 1,6V +* SW1ASTBY = 1,2V / reset value = 1,6V +*/ + /* + val = 0xc70c; + reg = 0x3000 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + */ + + /* +* Set PMIC switcher setting 1 +* SW1A = 1,2V / reset value = 1,6V +* SW1ADVS = 1,6V / reset value = 1,6V +* SW1ASTBY = 1,2V / reset value = 1,6V +*/ + /* + val = 0xc70c; + reg = 0x3200 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + */ + + /* +* Set PMIC switcher setting 5 +* SW5 = 5V +* SW5 = off +*/ + val = 0x021605; + reg = 0x3A00 | val | 0x8000; + if (spi_xfer(slave, 32, (uchar *)reg, (uchar *)val, + SPI_XFER_BEGIN | SPI_XFER_END)) + return -1; + + spi_release_bus(slave); + spi_free_slave(slave); + + return 0; +} + int dram_init (void) { gd-bd-bi_dram[0].start = PHYS_SDRAM_1; @@ -112,3 +239,18 @@ int checkboard (void) printf (Board: TQMA31\n); return 0; } + +int board_late_init(void) +{ + /* +* Must call this function in late init stage, because the SPI driver, +* required by this function, uses malloc(). The malloc space has not +* been setup in the board_init() stage. +*/ + if