Commit Graph

723742 Commits

Author SHA1 Message Date
Gregory CLEMENT e38c85644e i2c: mv64xxx: Add myself as maintainer for this driver
Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-26 18:51:29 +01:00
Gregory CLEMENT 1534156e99 i2c: mv64xxx: Fix clock resource by adding an optional bus clock
On Armada 7K/8K we need to explicitly enable the bus clock. The bus clock
is optional because not all the SoCs need them but at least for Armada
7K/8K it is actually mandatory.

The binding documentation is updating accordingly.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-26 18:51:03 +01:00
Gregory CLEMENT a9e94bb80e i2c: mv64xxx: Remove useless test before clk_disable_unprepare
clk_disable_unprepare() already checks that the clock pointer is valid.
No need to test it before calling it.

Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-26 18:49:45 +01:00
Gustavo A. R. Silva 4be49b5d65 i2c: mxs: use true and false for boolean values
Assign true or false to boolean variables instead of an integer value.

This issue was detected with the help of Coccinelle.

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-26 18:34:50 +01:00
Yixun Lan 7e4c9d9e50 i2c: meson: update doc description to fix build warnings
Add description for 'data' parameter and drop unused 'irq' memeber.

Here is the warnings:
drivers/i2c/busses/i2c-meson.c:103: warning: No description found for
parameter 'data'
drivers/i2c/busses/i2c-meson.c:103: warning: Excess struct member 'irq'
description in 'meson_i2c'

Reported-by: Wolfram Sang <wsa@the-dreams.de>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-26 18:33:44 +01:00
Jian Hu 931b18e92c i2c: meson: add configurable divider factors
This patch try to add support for I2C controller in Meson-AXG SoC,
Due to the IP changes between I2C controller, we need to introduce
a compatible data to make the divider factor configurable.

Reviewed-by: Neil Armstrong <narmstrong@baylibre.com>
Signed-off-by: Jian Hu <jian.hu@amlogic.com>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-24 07:24:55 +01:00
Jian Hu f13ebc4fbc dt-bindings: i2c: update documentation for the Meson-AXG
Update the doc to explicitly add Meson-AXG to support list

Signed-off-by: Jian Hu <jian.hu@amlogic.com>
Signed-off-by: Yixun Lan <yixun.lan@amlogic.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-24 07:24:30 +01:00
Fugang Duan 13d6eb20fc i2c: imx-lpi2c: add runtime pm support
Add runtime pm support to dynamically manage the clock to avoid enable/disable
clock in frequently that can improve the i2c bus transfer performance.

And use pm_runtime_force_suspend/resume() instead of lpi2c_imx_suspend/resume().

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-24 07:20:30 +01:00
Wolfram Sang fe34fbf93f i2c: rcar: fix some trivial typos in comments
Nothing big, but they get annoying after a while ;)

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-24 07:16:34 +01:00
Bartosz Golaszewski 19cfcafd7f i2c: davinci: fix the cpufreq transition
i2c_davinci_cpufreq_transition() is implemented in a way that will
block if it ever gets called while no transfer is in progress.

Not only that, but reinit_completion() is never called for xfr_complete.

Use the fact that cpufreq uses an srcu_notifier (running in process
context) for transitions and that the bus_lock is taken during the call
to master_xfer() and simplify the code by removing the transfer
completion entirely and protecting i2c_davinci_cpufreq_transition()
with i2c_lock/unlock_adapter().

Reported-by: David Lechner <david@lechnology.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Reviewed-by: Sekhar Nori <nsekhar@ti.com>
Tested-by: David Lechner <david@lechnology.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-24 07:14:59 +01:00
Wolfram Sang 5bacb56b2b i2c: rk3x: add proper kerneldoc header
gcc noticed the kerneldoc was wrongly formatted. Fix it!

drivers/i2c/busses/i2c-rk3x.c:164: warning:
  Cannot understand  * @grf_offset: ...
  on line 164 - I thought it was a doc line

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
2018-01-18 00:34:09 +01:00
Julia Lawall d032a2eb2e i2c: rk3x: account for const type of of_device_id.data
This driver creates a number of const structures that it stores in
the data field of an of_device_id array.

The data field of an of_device_id structure has type const void *, so
there is no need for a const-discarding cast when putting const values
into such a structure.

Furthermore, adding const to the declaration of the location that
receives a const value from such a field ensures that the compiler
will continue to check that the value is not modified.  The
const-discarding cast on the extraction from the data field is thus
no longer needed.

Done using Coccinelle.

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Reviewed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-18 00:10:30 +01:00
Wolfram Sang f89813ec8b i2c: acorn: remove outdated path from file header
That path has gone away for a long time. Move the HW name upwards for a
proper header.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-18 00:08:20 +01:00
Arnd Bergmann e199c285b6 i2c: acorn: add MODULE_LICENSE tag
As of v4.15, Kbuild warns about missing MODULE_LICENSE tags:

WARNING: modpost: missing MODULE_LICENSE() in drivers/i2c/busses/i2c-acorn.o

This adds a license, author and description tag, matching the
comment at the start of the acorn i2c driver.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-18 00:05:58 +01:00
Wolfram Sang 7d2c17f021 i2c: rcar: implement bus recovery
We can force levels of SCL and SDA, so we can use that for bus recovery.
Note that we cannot read SDA back, because we will only get the internal
state of the bus free detection.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:48 +01:00
Wolfram Sang 2806e6ad77 i2c: send STOP after successful bus recovery
If we managed to get a client release SDA again, send a STOP afterwards
to make sure we have a consistent state on the bus again.

Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:42 +01:00
Wolfram Sang 72b08fcc15 i2c: ensure SDA is released in recovery if SDA is controllable
If we have a function to control SDA, we should ensure that SDA is not
held down by us. So, release the GPIO in this case.

Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:30 +01:00
Wolfram Sang 8092178ffe i2c: add 'set_sda' to bus_recovery_info
This will be needed when we want to create STOP conditions, too, later.
Create the needed fields and populate them for the GPIO case if the GPIO
is set to output.

Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:19 +01:00
Wolfram Sang 6c92204e44 i2c: add identifier in declarations for i2c_bus_recovery
No reason to have them undefined, so let's add them.

Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:03 +01:00
Wolfram Sang 766a4f27f3 i2c: make kerneldoc about bus recovery more precise
"Used internally" is vague. What it actually means is that those fields
are populated by the core if valid GPIOs are provided. Change the
comments to reflect that.

Tested-by: Phil Reid <preid@electromag.com.au>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-16 00:04:02 +01:00
Andrzej Hajda 4d3ea4e1c3 i2c: exynos5: change internal transmission timeout to 100ms
Exynos-I2C uses default timeout of 1 second for the whole transaction,
including re-transmissions due to arbitration lost errors (-EAGAIN).
To allow re-transmissions driver's internal timeout should be significantly
lower, 100ms seems to be good candidate.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 21:54:28 +01:00
Radu Rendec 5cd5f0bb0d i2c: ismt: 16-byte align the DMA buffer address
Use only a portion of the data buffer for DMA transfers, which is always
16-byte aligned. This makes the DMA buffer address 16-byte aligned and
compensates for spurious hardware parity errors that may appear when the
DMA buffer address is not 16-byte aligned.

The data buffer is enlarged in order to accommodate any possible 16-byte
alignment offset and changes the DMA code to only use a portion of the
data buffer, which is 16-byte aligned.

The symptom of the hardware issue is the same as the one addressed in
v3.12-rc2-5-gbf41691 and manifests by transfers failing with EIO, with
bit 9 being set in the ERRSTS register.

Signed-off-by: Radu Rendec <radu.rendec@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 21:02:43 +01:00
Arseny Solokha 38a99bd773 i2c: mpc: always determine I2C clock prescaler at runtime
Remove the facility for setting the prescaler value at compile time
entirely. It was only used for two SoCs, duplicating the actual value
for one of them and setting sometimes bogus value for another. Make all
MPC8xxx SoCs obtain their actual I2C clock prescaler from a single place
in the code.

Changes from v2:
- left Device Tree compatibles in place

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 19:19:55 +01:00
Arseny Solokha 7575a745f9 i2c: mpc: fix PORDEVSR2 mask for MPC8533/44
According to the reference manuals for the corresponding SoCs, SEC
frequency ratio configuration is indicated by bit 26 of the POR Device
Status Register 2. Consequently, SEC_CFG bit should be tested by mask 0x20,
not 0x80. Testing the wrong bit leads to selection of wrong I2C clock
prescaler on those SoCs.

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 19:16:14 +01:00
Arseny Solokha f6214f6f2b i2c: mpc: unify obtaining the MPC8533/44 I2C clock prescaler w/ MPC8xxx
Commit 8ce795cb0c ("i2c: mpc: assign the correct prescaler from SVR")
introduced the common helper function for obtaining the actual clock
prescaler value for MPC85xx. However, getting the prescaler for MPC8544
which depends on the SEC frequency ratio on this platform, has been always
performed separately based on the corresponding Device Tree configuration.

Move special handling of MPC8544 into that common helper. Make it dependent
on the SoC version and not on Device Tree compatible node, as is the case
with all other SoCs. Handle MPC8533 the same way which is similar
to MPC8544 in this regard, according to AN2919 "Determining the I2C
Frequency Divider Ratio for SCL".

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 19:13:33 +01:00
Arseny Solokha 6d10613919 i2c: mpc: get MPC8xxx I2C clock prescaler before using it in calculations
Obtaining the actual I2C clock prescaler value in mpc_i2c_setup_8xxx() only
happens when the clock parameter is set to something other than
MPC_I2C_CLOCK_LEGACY. When the clock parameter is exactly
MPC_I2C_CLOCK_LEGACY, the prescaler parameter is used in arithmetic
division as provided by the caller, resulting in a division by zero
for the majority of processors supported by the module.

Avoid division by zero by obtaining the actual I2C clock prescaler
in mpc_i2c_setup_8xxx() unconditionally regardless of the passed clock
value.

Signed-off-by: Arseny Solokha <asolokha@kb.kras.ru>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 19:13:06 +01:00
Radu Rendec aad550f93f i2c: ismt: dump registers at the end of transactions
This patch dumps general and master registers at the end of transactions
when debugging is enabled. Previously, registers were only dumped before
submitting new descriptors (at the beginning of transactions).

This helps debugging if some registers change as result of a failed
transaction (e.g. bits are set in the ERRSTS general register).

Signed-off-by: Radu Rendec <radu.rendec@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 18:03:56 +01:00
Wolfram Sang 6e318d9e37 i2c: sh_mobile: let r8a7790 (R-Car H2) use the new formula
Make use of the new formula for more precise bus frequencies.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 18:01:14 +01:00
Wolfram Sang 4ecfb9d3b2 i2c: sh_mobile: add new frequency calculation for later SoC
The formula to generate the desired bus speeds has changed a little over
time. Implement the new formula and allow drivers to opt-in by changing
to this new config set. Ensure in probe that we don't divide by zero.
The returned values on a R-Car H2 (r8a7790/Lager board) match the
suggested values in the datasheet.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 18:01:14 +01:00
Wolfram Sang c3449f73a8 i2c: sh_mobile: add helper to check frequency calculations
Because we will add a second formula soon, put the sanity checks for the
computed results into a separate function.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 18:01:03 +01:00
Wolfram Sang 023c22fd82 i2c: sh_mobile: let RuntimePM do the clock handling
Start RuntimePM a bit earlier, so we can use it to enable the clock
during probe for frequency calculations. Make sure it is enabled before
calling setup().

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 17:58:56 +01:00
Wolfram Sang b3750b6278 i2c: sh_mobile: require setup callback
Require the setup callback and move the frequency calculation into it.
This is in preparation for supporting multiple formulas.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 17:58:50 +01:00
Wolfram Sang 12742b6ac1 i2c: sh_mobile: allow setup callback to return errno
The setup callback will be more generic and, thus, need to be able to
return error codes. Change the return type to 'int' for that.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 17:58:45 +01:00
Wolfram Sang 9e42213116 i2c: sh_mobile: move type detection upwards
For refactoring reasons, we will need this information before the setup
callback. Also, simplify the comment to a oneliner.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-15 17:58:39 +01:00
Jan Kundrát f11a04464a i2c: gpio: Enable working over slow can_sleep GPIOs
"Slow" GPIOs (usually those connected over an SPI or an I2C bus) are,
well, slow in their operation. It is generally a good idea to avoid
using them for time-critical operation, but sometimes the hardware just
sucks, and the software has to cope. In addition to that, the I2C bus
itself does not actually define any strict timing limits; the bus is
free to go all the way down to DC. The timeouts (and therefore the
slowest acceptable frequency) are present only in SMBus.

The `can_sleep` is IMHO a wrong concept to use here. My SPI-to-quad-UART
chip (MAX14830) is connected via a 26MHz SPI bus, and it happily drives
SCL at 200kHz (5µs pulses) during my benchmarks. That's faster than the
maximal allowed speed of the traditional I2C.

The previous version of this code did not really block operation over
slow GPIO pins, anyway. Instead, it just resorted to printing a warning
with a backtrace each time a GPIO pin was accessed, thereby slowing
things down even more.

Finally, it's not just me. A similar patch was originally submitted in
2015 [1].

[1] https://patchwork.ozlabs.org/patch/450956/

Signed-off-by: Jan Kundrát <jan.kundrat@cesnet.cz>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-04 01:02:55 +01:00
Jun Gao f6762cedbe i2c: mediatek: Enable i2c module clock before i2c registers access.
Make sure i2c module clock has been enabled before i2c registers
access.

Signed-off-by: Jun Gao <jun.gao@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-04 00:54:02 +01:00
Jun Gao 5a10e7d7aa i2c: mediatek: Add i2c compatible for MediaTek MT2712
Add i2c compatible for MT2712. Compare to MT8173 i2c controller,
internal divider of i2c source clock need to be configured for
MT2712 i2c speed calculation.

Signed-off-by: Jun Gao <jun.gao@mediatek.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-04 00:53:26 +01:00
Jun Gao 0578c660b7 dt-bindings: i2c: Add MediaTek MT2712 i2c binding
Add MT2712 i2c binding to binding file. Compare to MT8173 i2c
controller, MT2712 has timing adjust registers which can adjust
the internal divider of i2c source clock, SCL duty cycle, SCL
compare point, start(repeated start) and stop time, SDA change
time.

Signed-off-by: Jun Gao <jun.gao@mediatek.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
2018-01-04 00:53:05 +01:00
Wolfram Sang fddfa22a44 AT24 updates for 4.16 merge window
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEFp3rbAvDxGAT0sefEacuoBRx13IFAlpM+BAACgkQEacuoBRx
 13KHtxAAj8uQ/ZEMz5vPQd4kQ3pn2a5Ts/yrAc8PPfk8SrBvMVk7KWNTRmbQgF2d
 EcL0Xs8AtiOYdSd1KmEQrkHtjJsJxRW27IsDGHJuoEc3aBrmAStgGvUUFROncZWU
 fHUm2Hy6Vw46Bx7HzxelmN5vjFHIZFdnx0sa6EfLL8Pui4VUVga7u9c8ezGL71MC
 TnXUCl6roWsrQhxoEWwX+HnzT0OI/Q+eQdvycWVyAOJDNga0F7+5KFhP6G1IOzsR
 QaUoowydRlSpot6dCRHeZ8+0aGtLXcZsMmQrg735ngdVT7ROZtY6dpXEpyn/KQHS
 ysFtaxJ8PPiC6PY0sXmztWBgZMLTph555Uqp3PSIlpuP5qFMqiTi8BoCv+UvXwA1
 QAyPd7QUrefLrhFb21v3RlDNdalMAU8NGKh8nEkaP664HJjw4TvRlWOcyxsmcsOI
 7szGsF/hsqQeaVrVsHQbF+sEy16u98VPIGA1k+KCtY0334vsMKOtfndXnS2OeR5l
 tJncNkfYD/0PeG479Wq4T42NOe6w90JmDKzWnLuDcY/zCJ7/AjJPp95AwyK/HPDc
 F5GcwC1WmcbcYkuKCG9c2nMxidpH8QZ5sei1TWey6lM4lAAHnQrXhohQw4zJcjst
 Q4ZRnXWGizSWOSTVQHVlmdUcPs/DlKPyDlcoTSEOD6JDhvl6AEY=
 =C2BD
 -----END PGP SIGNATURE-----

Merge tag 'at24-4.16-updates-for-wolfram' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux into i2c/for-4.16

"AT24 updates for 4.16 merge window

The driver has been converted to using regmap instead of raw i2c and
smbus calls which shrank the code significantly.

Device tree binding document has been cleaned up. Device tree support in
the driver has been improved and we now support all at24 models as well
as two new DT properties (no-read-rollover and wp-gpios).

We no longer user unreadable magic values for driver data as the way it
was implemented caused problems for some EEPROM models - we switched to
regular structs.

Aside from that, there's a bunch of coding style fixes and minor
improvements all over the place."
2018-01-03 22:50:51 +01:00
Bartosz Golaszewski 0f30aca72c eeprom: at24: extend the list of chips supported in DT
Add all supported at24 variants to the of_match table.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
2018-01-02 17:52:45 +01:00
Bartosz Golaszewski e36820425f dt-bindings: at24: extend the list of supported chips
Add other variants of at24 EEPROMs we support in the driver to the
list of allowed compatible fallbacks.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2018-01-02 17:52:35 +01:00
Bartosz Golaszewski e32a1f30b6 dt-bindings: at24: fix formatting and style
Make formatting and style consistent for the entire document.

This patch doesn't change the content of the binding.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2018-01-02 17:52:17 +01:00
Bartosz Golaszewski 6da28acf74 dt-bindings: at24: consistently document the compatible property
Current description of the compatible property for at24 is quite vague.

State explicitly that any "<manufacturer>,<model>" pair is accepted as
long as a correct fallback is used for non-atmel chips.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Rob Herring <robh@kernel.org>
2018-01-02 17:52:03 +01:00
Bartosz Golaszewski 98fb3a3473 eeprom: at24: fix a whitespace error in platform data
Replace spaces with tabs in the definition of AT24_FLAG_NO_RDROL.

Fixes: 9d404411091c ("eeprom: at24: support eeproms that do not auto-rollover reads")
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2018-01-01 19:40:50 +01:00
Bartosz Golaszewski 6ce261e87f eeprom: at24: add support for the write-protect pin
AT24 EEPROMs have a write-protect pin, which - when pulled high -
inhibits writes to the upper quadrant of memory (although it has been
observed that on some chips it disables writing to the entire memory
range).

On some boards, this pin is connected to a GPIO and pulled high by
default, which forces the user to manually change its state before
writing. On linux this means that we either need to hog the line all
the time, or set the GPIO value before writing from outside of the
at24 driver.

Make the driver check if the write-protect GPIO was defined in the
device tree and pull it low whenever writing to the EEPROM.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
2018-01-01 19:40:50 +01:00
Bartosz Golaszewski 3f3d8ef7f4 dt-bindings: at24: new optional property - wp-gpios
AT24 EEPROMs have a write-protect pin, which - when pulled high -
inhibits writes to the upper quadrant of memory (although it has been
observed that on some chips it disables writing to the entire memory
range).

On some boards, this pin is connected to a GPIO and pulled high by
default, which forces the user to manually change its state before
writing. On linux this means that we either need to hog the line all
the time, or set the GPIO value before writing from outside of the
at24 driver.

Add a new optional property to the device tree binding document, which
allows to specify the GPIO line to which the write-protect pin is
connected.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Rob Herring <robh@kernel.org>
2018-01-01 19:40:50 +01:00
Sven Van Asbroeck ef542e59d7 eeprom: at24: remove temporary fix for at24mac402 size
The chip size passed via devicetree, i2c, or acpi device ids is now no
longer limited to a power of two. So the temporary fix can be removed.

Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2018-01-01 19:40:49 +01:00
Sven Van Asbroeck b680f4fa74 eeprom: at24: convert magic numbers to structs
Fundamental properties such as capacity and page size differ among
at24-type chips. But these chips do not have an id register, so this
can't be discovered at runtime.

Traditionally, at24-type eeprom properties were determined in two ways:
- by passing a 'struct at24_platform_data' via platform_data, or
- by naming the chip type in the devicetree, which passes a 'magic
  number' to probe(), which is then converted to a 'struct
  at24_platform_data'.

Recently a bug was discovered because the magic number rounds down all
chip sizes to the lowest power of two. This was addressed by
a work-around commit 5478e478ee ("eeprom: at24: correctly set the
size for at24mac402"), with the wish that magic numbers should over
time be converted to structs.

This patch replaces the magic numbers with 'struct at24_chip_data'.

Signed-off-by: Sven Van Asbroeck <svendev@arcx.com>
Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2018-01-01 19:40:49 +01:00
Bartosz Golaszewski eef6939849 eeprom: at24: code shrink
A regmap_config struct is pretty big and declaring two of them
statically just to tweak the reg_bits value adds unnecessary bloat.

Declare the regmap config locally in at24_probe() instead.

Bloat-o-meter output for ARM:

add/remove: 0/2 grow/shrink: 1/0 up/down: 4/-272 (-268)
Function                                     old     new   delta
at24_probe                                  1560    1564      +4
regmap_config_8                              136       -    -136
regmap_config_16                             136       -    -136
Total: Before=7012, After=6744, chg -3.82%

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2018-01-01 19:40:49 +01:00
Bartosz Golaszewski ec3c2d518b eeprom: at24: use a common prefix for all symbols in at24.c
There are a couple symbols defined in the driver source file which are
missing the at24_ prefix. This patch fixes that.

For module params: use module_param_named() in order to not break
userspace.

Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
2018-01-01 19:40:49 +01:00