base-files: define yes/no as valid boolean options
[openwrt.git] / target / linux / mvebu / patches-3.10 / 0035-i2c-mv64xxx-Set-bus-frequency-to-100kHz-if-clock-fre.patch
1 From 76de914223ec09274a7857e0d8cd7b739205dc3c Mon Sep 17 00:00:00 2001
2 From: Gregory CLEMENT <gregory.clement@free-electrons.com>
3 Date: Fri, 21 Jun 2013 15:32:06 +0200
4 Subject: [PATCH 035/203] i2c: mv64xxx: Set bus frequency to 100kHz if
5  clock-frequency is not provided
6
7 This commit adds checking whether clock-frequency property acquisition
8 has succeeded. If not, the frequency is set to 100kHz by default.
9
10 The Device Tree binding documentation is updated accordingly.
11
12 Based on the intials patches from Zbigniew Bodek
13
14 Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com>
15 Signed-off-by: Zbigniew Bodek <zbb@semihalf.com>
16 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
17 ---
18  Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt | 6 +++++-
19  drivers/i2c/busses/i2c-mv64xxx.c                      | 6 +++++-
20  2 files changed, 10 insertions(+), 2 deletions(-)
21
22 --- a/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
23 +++ b/Documentation/devicetree/bindings/i2c/i2c-mv64xxx.txt
24 @@ -6,7 +6,11 @@ Required properties :
25   - reg             : Offset and length of the register set for the device
26   - compatible      : Should be "marvell,mv64xxx-i2c"
27   - interrupts      : The interrupt number
28 - - clock-frequency : Desired I2C bus clock frequency in Hz.
29 +
30 +Optional properties :
31 +
32 + - clock-frequency : Desired I2C bus clock frequency in Hz. If not set the
33 +default frequency is 100kHz
34  
35  Examples:
36  
37 --- a/drivers/i2c/busses/i2c-mv64xxx.c
38 +++ b/drivers/i2c/busses/i2c-mv64xxx.c
39 @@ -580,7 +580,11 @@ mv64xxx_of_config(struct mv64xxx_i2c_dat
40                 goto out;
41         }
42         tclk = clk_get_rate(drv_data->clk);
43 -       of_property_read_u32(np, "clock-frequency", &bus_freq);
44 +
45 +       rc = of_property_read_u32(np, "clock-frequency", &bus_freq);
46 +       if (rc)
47 +               bus_freq = 100000; /* 100kHz by default */
48 +
49         if (!mv64xxx_find_baud_factors(bus_freq, tclk,
50                                        &drv_data->freq_n, &drv_data->freq_m)) {
51                 rc = -EINVAL;