lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMo8Bf+XJY_bY+OB2i_SZQmAavwERG39BR8FVj202V-E3UidPg@mail.gmail.com>
Date:	Thu, 22 Jan 2015 18:01:24 +0300
From:	Max Filippov <jcmvbkbc@...il.com>
To:	Wolfram Sang <wsa@...-dreams.de>
Cc:	Peter Korsgaard <jacmet@...site.dk>, linux-i2c@...r.kernel.org,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] i2c-ocores: add common clock support

On Thu, Jan 22, 2015 at 5:45 PM, Wolfram Sang <wsa@...-dreams.de> wrote:
>> @@ -320,9 +322,23 @@ static int ocores_i2c_of_probe(struct platform_device *pdev,
>>       }
>>
>>       if (of_property_read_u32(np, "clock-frequency", &val)) {
>> -             dev_err(&pdev->dev,
>> -                     "Missing required parameter 'clock-frequency'\n");
>> -             return -ENODEV;
>> +             struct clk *clk = devm_clk_get(&pdev->dev, NULL);
>> +
>> +             if (!IS_ERR(clk)) {
>> +                     int ret = clk_prepare_enable(clk);
>> +
>> +                     if (ret) {
>> +                             dev_err(&pdev->dev,
>> +                                     "clk_prepare_enable failed: %d\n", ret);
>> +                             return ret;
>> +                     }
>> +                     i2c->clk = clk;
>> +                     val = clk_get_rate(clk);
>> +             } else {
>> +                     dev_err(&pdev->dev,
>> +                             "Missing required parameter 'clock-frequency'\n");
>> +                     return -ENODEV;
>> +             }
>
> Either NAK or I don't understand the logic here :) If a dts does NOT
> have the bus-speed set by 'clock-frequency', then we take the value of
> the clock assigned to this platform_device?
>
> The usual thing to do when 'clock-frequency' is not set is to default to
> 100kHz.

The clock here is not the i2c bus clock, but the clock input of the
controller. The function ocores_init initializes the prescaler register of
the controller so that the bus clock equals 100kHz (internal clock
runs at 500kHz):

static void ocores_init(struct ocores_i2c *i2c)
{
        int prescale;
...
        prescale = (i2c->clock_khz / (5*100)) - 1;
        oc_setreg(i2c, OCI2C_PRELOW, prescale & 0xff);
        oc_setreg(i2c, OCI2C_PREHIGH, prescale >> 8);
...

Then yes, when there's no 'clock-frequency' we take the value of the
clock assigned to this platform_device, which in turn comes from the
'clk' property.

-- 
Thanks.
-- Max
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ