summaryrefslogtreecommitdiffstats
path: root/drivers/i2c/mvtwsi.c
Commit message (Collapse)AuthorAgeFilesLines
* i2c: mvtwsi: Eliminate twsi_control_flagsChris Packham2016-05-171-33/+29
| | | | | | | | | | | | | In a system where the initial u-boot location is genuinely NOR flash (as opposed to RAM or a cache-line setup by a pre-bootloader) writes to the data section are problematic. At best these writes have no effect, at worst they put the flash memory into a status mode which changes the executable code underneath us. Pass around a stack variable from the top of the twsi i2c driver to avoid writing to global data. Signed-off-by: Chris Packham <judge.packham@gmail.com>
* mvtwsi: Fix breakage introduced by "Fix mvtwsi not working on sun6i and ↵Hans de Goede2016-01-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | newer sunxi SoCs" "Fix mvtwsi not working on sun6i and newer sunxi SoCs" includes the following: @@ -189,7 +200,8 @@ static int twsi_start(struct i2c_adapter *adap, int expected_status) /* globally set TWSIEN in case it was not */ twsi_control_flags |= MVTWSI_CONTROL_TWSIEN; /* assert START */ - writel(twsi_control_flags | MVTWSI_CONTROL_START, &twsi->control); + twsi_control_flags |= MVTWSI_CONTROL_START | MVTWSI_CONTROL_CLEAR_IFLG; + writel(twsi_control_flags, &twsi->control); /* wait for controller to process START */ return twsi_wait(adap, expected_status); } The modification of twsi_control_flags done here was introduced while merging to fix a line > 80 chars, but twsi_control_flags is a global variable and should not be modified like this here, this commit fixes this, restoring mvtwsi functionality. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* sunxi: Add support for the I2C controller which is part of the PRCMJelle van der Waa2016-01-211-0/+11
| | | | | | | | | | | Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl> [hdegoede@redhat.com: Minor cleanups] Signed-off-by: Hans de Goede <hdegoede@redhat.com> applied with fixing 2 checkpatch warnings: WARNING: please, no space before tabs Signed-off-by: Heiko Schocher <hs@denx.de>
* i2c: mvtwsi: Fix mvtwsi not working on sun6i and newer sunxi SoCsHans de Goede2016-01-211-4/+16
| | | | | | | | | | | | | | | On sun6i and newer IFLG is a write-clear bit which is cleared by writing 1, rather then a normal r/w bit which is cleared by writing 0. Signed-off-by: Hans de Goede <hdegoede@redhat.com> applied with fixing 3 checkpatch warnings in drivers/i2c/mvtwsi.c: WARNING: line over 80 characters ERROR: code indent should use tabs where possible WARNING: please, no spaces at the start of a line Signed-off-by: Heiko Schocher <hs@denx.de>
* arm: mvebu: Move SoC selection (A38X vs AXP) into KconfigStefan Roese2016-01-141-1/+1
| | | | | | | | | | | | | | | | | | Until now, the SoC selection for the ARCH_MVEBU platforms has been done in the config header. Using CONFIG_ARMADA_XP in a non-clear way. As it needed to get selected for AXP and A38x based boards. This patch now changes this to move the SoC selection to Kconfig. And also uses CONFIG_ARCH_MVEBU as a common define for both AXP and A38x. This makes things a bit clearer - especially for new board additions. Additionally the defines CONFIG_SYS_MVEBU_DDR_AXP and CONFIG_SYS_MVEBU_DDR_A38X are replaced with the already available CONFIG_ARMADA_38X and CONFIG_ARMADA_XP. And CONFIG_DDR3 is removed, as its not referenced anywhere. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Luka Perkov <luka.perkov@sartura.hr>
* i2c: mvtwsi: Support for up to 4 different controllersPaul Kocialkowski2015-04-151-29/+99
| | | | | | | | | | | | Orion5x, Kirkwood and Armada XP platforms come with a single TWSI (I2C) MVTWSI controller. However, other platforms using MVTWSI may come with more: this is the case on Allwinner (sunxi) platforms, where up to 4 controllers can be found on the same chip. Signed-off-by: Paul Kocialkowski <contact@paulk.fr> Acked-by: Heiko Schocher <hs@denx.de> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* i2c: mvtwsi: Fix problem with baud rate calculationStefan Roese2015-03-181-8/+9
| | | | | | | | | | | | | | | | | | | | The current implementation for baudrate calculation is incorrect. This part from the formula: "2 ^ (n + 1)" is not equivalent to (1 << n) but to (2 << n)! This patch fixes this and moves this calculation to a function instead of using a macro. This new function is taken from the Linux kernel. This was detected and tested on the Marvell Armada A38x DB-88F6820-GP eval board. Signed-off-by: Stefan Roese <sr@denx.de> Cc: Prafulla Wadaskar <prafulla@marvell.com> Cc: Luka Perkov <luka.perkov@sartura.hr> Cc: Hans de Goede <hdegoede@redhat.com> Cc: Ian Campbell <ijc@hellion.org.uk> Cc: Heiko Schocher <hs@denx.de> Acked-by: Hans de Goede <hdegoede@redhat.com>
* i2c: mvtwsi: Add support for Marvell Armada XPStefan Roese2014-10-231-1/+1
| | | | | | | | To support the Armada XP SoC, we just need to include the correct header. Signed-off-by: Stefan Roese <sr@denx.de> Acked-by: Heiko Schocher <hs@denx.de> Tested-by: Luka Perkov <luka@openwrt.org>
* arm: marvell: Move arch/kirkwood.h to arch/soc.hStefan Roese2014-10-231-1/+1
| | | | | | | | | This move makes is possible to use this header not only from kirkwood platforms but from all Marvell mvebu platforms. Signed-off-by: Stefan Roese <sr@denx.de> Tested-by: Luka Perkov <luka@openwrt.org> Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
* sunxi: Add i2c supportHans de Goede2014-07-181-0/+18
| | | | | | | | | | | | | Add support for the i2c controller found on all Allwinner sunxi SoCs, this is the same controller as found on the Marvell orion5x and kirkwood SoC families, with a slightly different register layout, so this patch uses the existing mvtwsi code. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Ian Campbell <ijc@hellion.org.uk> Acked-By: Prafulla Wadaskar <prafulla@marvell.com> Acked-by: Heiko Schocher <hs@denx.de> [ ijc -- updated u-boot-spl-fel.lds ]
* mvtwsi: convert to CONFIG_SYS_I2C frameworkHans de Goede2014-07-161-38/+32
| | | | | | | | | | | | Note this has only been tested on Allwinner sunxi devices (support for which gets introduced by a later patch). The kirkwood changes have been compile tested using the wireless_space board config, the orion5x changes have been compile tested using the edminiv2 board config. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Heiko Schocher <hs@denx.de>
* mvtwsi: Remove unnecessary twsi_baud_rate and twsi_slave_address globalsHans de Goede2014-05-141-19/+4
| | | | | | | | | These are used only once, so their is no need to have them global. This also stops mvtwsi from using any bss vars making it easier to use before dram init (to talk to the pmic to set the dram voltage). Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* mvtwsi: Fix clock programmingHans de Goede2014-05-141-5/+2
| | | | | | | | | | | | | | | | The TWSI_FREQUENCY macro was wrong in 2 ways: 1) It was casting the result of the calculations to an u8, while i2c clk rates are often >= 100Khz which won't fit in a u8, drop the cast. 2) It had an extra factor of 2 in the divider which neither the datasheet nor the Linux driver have. The comment for the default value was wrongly saying that m lives in bits 4-7, while in reality it is in bits 3-6, as can be seen from the correct shift by 3 used in i2c_init(). While at it remove the unused twsi_actual_speed variable. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
* Add GPL-2.0+ SPDX-License-Identifier to source filesWolfgang Denk2013-07-241-17/+1
| | | | | | Signed-off-by: Wolfgang Denk <wd@denx.de> [trini: Fixup common/cmd_io.c] Signed-off-by: Tom Rini <trini@ti.com>
* Replace obsolete e-mail addressAlbert ARIBAUD2011-04-271-1/+1
| | | | Signed-off-by: Albert ARIBAUD <albert.u.boot@aribaud.net>
* i2c: rewrite mvtwsi, support orion5x and kirkwoodAlbert Aribaud2010-08-301-409/+341
| | | | | | | | | This rewrite of the mvtwsi driver is 25% smaller and much faster and simpler than the previous code. Signed-off-by: Albert Aribaud <albert.aribaud@free.fr> Acked-by: Prafulla Wadaskar<prafulla@marvell.com> Acked-by: Heiko Schocher<hs@denx.de>
* i2c: rename kirkwood_i2c to mvtwsiAlbert Aribaud2010-08-301-0/+496
This driver is not kirkwood-specific and can also be used e.g. by orion5x. Rename to a SoC-neutral name. Signed-off-by: Albert Aribaud <albert.aribaud@free.fr> Acked-by: Prafulla Wadaskar<prafulla@marvell.com> Acked-by: Heiko Schocher<hs@denx.de>
OpenPOWER on IntegriCloud