From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753236AbbE0QqT (ORCPT ); Wed, 27 May 2015 12:46:19 -0400 Received: from mail-by2on0134.outbound.protection.outlook.com ([207.46.100.134]:43578 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753172AbbE0QqM (ORCPT ); Wed, 27 May 2015 12:46:12 -0400 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=yorksun@freescale.com; Message-ID: <5565F4CA.4080105@freescale.com> Date: Wed, 27 May 2015 09:46:02 -0700 From: York Sun User-Agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Sebastian Hesselbarth , Guenter Roeck , CC: , , , , Subject: Re: clock driver References: <5564C58B.9050400@freescale.com> <20150526223829.GA26454@roeck-us.net> <55650DBA.5000304@freescale.com> <5565108D.2020502@freescale.com> <55656D96.9030603@gmail.com> <5565DDCA.2000308@freescale.com> <5565F40E.70805@gmail.com> In-Reply-To: <5565F40E.70805@gmail.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [192.88.168.49] X-ClientProxiedBy: SN1PR15CA0028.namprd15.prod.outlook.com (25.163.200.38) To BLUPR03MB150.namprd03.prod.outlook.com (10.255.212.18) X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB150;2:yXtyzI1QNTFgKi8YnuCf4+PnEVTHzvp5sbrdvXZuDTFV9DEhs/2fwFydpDCoc1Be;2:BO8Ricip61k+RoKTIKDES2tqfviGU4vVSe6PBGpuQLRCQC7hjffQ5KZgwRyq2OvUAeSZXNMZwLnak4Li7NbNqDbKyZgDY8AssTk3ch0TfRSbWsS6a4F2HSFLTu8tg4Xrl14y6vxBUfo2TJnc5XJNmw==;6:BG6LV4ZQP4DPXBlbd3oBm0WpLkADkogNNXHEgkp2tNQtjfgJr7bOnRIMQvK5J6fFCtb7wRIbuj5x+SxDP62MxFrUvhHhkTdvVrAwNPkXrIeV42R2daMHQozWrBi6sOCbL0oDAO0kK2x35vdPiCzD2PwkwfpBvQRDfsDNpX5J9iosHkl3HRBSZ+b7eu3SAQpAzoRYLgdF1Y8tPS3IdLYe6TsWMItdbEGG6/uBBjZyV7/O1q3dsGrhwSpKZk6OmkAuCu0cn41nUDUjqGhZEvLgNbyHbnoh2tTrducXWq5kEjuXQ5PLBTRiGdGc4sQSTtLB4SOxWyY67lWy2Bj2iyi62IUFfdj5tmYZSHYKlSibtBJe+mzqQ5VfUkDRvwrkAL6WOMEGVO/uRTQT4rF+uCImUDouBNVZKH+wB8divJ7E2yDL+s2r5rdiCK3DmTD2icl0L95K6BZqnBMCcJeUrESnbIUMqFN6D0Y+zvW11trRypMSt+Q3RDF/NUbV02Hc9Gx5npdzc1v61OORTk+EjVOL3dt3dp0TdmHZY+4NbYI07OTzk6mStIZIsFMqKnGWkxgNFrv0fjoDAUNliNR22kOerqnKZ2GMnzjY/eYzjigPQSI= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB150;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB1345; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(520003)(5005006)(3002001);SRVR:BLUPR03MB150;BCL:0;PCL:0;RULEID:;SRVR:BLUPR03MB150; X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB150;3:PTcvFvvHJ2IybCHH7HOV44hEX+aL1sL8zURoP7eHyK1H5K+MfXmoDJe1W9EKPpeVKZlJtPacKWnChnRYPCnqgtIZ75s3bD4rEHhIjIPSz60BdzGGzFqo3h5/HCYN1iBG3slBrOcbsRo5daawJdFCeNAkt1eKFKHKHA9GiJ9oPu/2n6/Bih75NMJs+shpiA9LW9uc8Tf41bhD3E00rbvwmnNy0aqAq5kwZBWy8T4uNDo+nkx97ATGVAG2fsYB3xZ5W7D1ekMLiBDodENSZXmPT2Udtp2/7lVCt1juUxlrs9otNjNB5HK/yafGJN8bvZGx X-Forefront-PRVS: 05891FB07F X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(6009001)(479174004)(51704005)(189002)(24454002)(51914003)(199003)(377454003)(122386002)(93886004)(23746002)(77096005)(87976001)(105586002)(50466002)(92566002)(2950100001)(59896002)(40100003)(68736005)(36756003)(77156002)(62966003)(66066001)(65806001)(65956001)(46102003)(80316001)(33656002)(64706001)(83506001)(221733001)(47776003)(5001960100002)(86362001)(64126003)(189998001)(87266999)(5001860100001)(101416001)(42186005)(106356001)(5001770100001)(5001830100001)(97736004)(81156007)(54356999)(65816999)(4001350100001)(76176999)(50986999)(4001540100001)(111123002);DIR:OUT;SFP:1102;SCL:1;SRVR:BLUPR03MB150;H:[10.214.80.244];FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;BLUPR03MB150;9:69QcJ9C8kwIP3F/mP/yzt/ajk1DZdTGZ7de3R3M?= =?Windows-1252?Q?UF/OgfD5OxqWsliN9E4ndq87b6ZhFKFxXiHx7VHrPLO9oc411cisVlZl?= =?Windows-1252?Q?YACkj23pUesJbbq4itfK1ePS/0F9gLS/dYGjqZhl0sI16yGDbZoEm8x1?= =?Windows-1252?Q?sk4fq5X8l3lUprwqusv/98TPZZFduGGuHVZ6R3OWF0KKBlpz65G6Ry4F?= =?Windows-1252?Q?yutJRdjnD74COwtfp+eJk2AxMKKqXq8MJWH33iQbBcfDyDJsttM08wqG?= =?Windows-1252?Q?AcN0AL10ajLdLHpDSMWFeviMfzgboTIaXi6ksVQYI44JMIAet5OEEkxF?= =?Windows-1252?Q?sNs18+qtnWYvXQDz/ojsShfd9z0VvhMTq4ausZCeQ293w9PGpf0KDGow?= =?Windows-1252?Q?MZOiVBwO5HK8S3+XMvr1FtMqrADrLzQtLj5pE8qSWzMq4GWKigq6HsXH?= =?Windows-1252?Q?ZLF02R+/WYo0gyQeKmP/IVaGwRP67rFAWkZNNQpPQTIZZb2Lh9gWqFit?= =?Windows-1252?Q?Y5KBDaHBFOzMzaETCuQoGCwhmZtCvZYCmu8WDwxFWkrxzMQ1c0nW1gnq?= =?Windows-1252?Q?P4kaCFDaWJfuEAzu3s3FWMh/XavJXT/VuchqtcjvNv0Fm3GAMlpSVVej?= =?Windows-1252?Q?YyQl5nTs1X2TNDpDkGfixPRxfs9iXKm/nTFkb+ExICJWwA6CckoZ6kBz?= =?Windows-1252?Q?eXc2v3CxMFvr16qPQPq3HJ8Ee641pYwlHOKzj7kWyH+XgGqdQEkCiunF?= =?Windows-1252?Q?7yCB6HUGgE8OF3Iss0jSNxzNnokKXuMlnGWMEx7tgE7kev4p9V+iXe4I?= =?Windows-1252?Q?a6PYABCnLhJoaq31Y9dDi67QEJIoj1Daf3e8cp87eKEOf8CMzk9G+gDL?= =?Windows-1252?Q?3dGY42gbxXKZ56hiQVKMvVSOEuMCp/hmd6mKUrB73b4zLi6Aq7qvPtbz?= =?Windows-1252?Q?Tmm8oxdZ/949cOzeCXhs0cQvgf9BtV2hu33owN4YuqSFIxHBDuWT3mT/?= =?Windows-1252?Q?SMImoDY/coIfvIEnAeP1Zu49K5HBkbAM/Nn+wVmvOSKGVmh96kffNUng?= =?Windows-1252?Q?WeLdHY9qrgK6L7UpGzGiAgKl14awdE+v34YB5XCki/CpQ9KDdRvl6N8Z?= =?Windows-1252?Q?PHtqLvxjC9r5AlxHAgK5ktGDt3pstrIHk81SqT50zFpV9NuGVH8je+0m?= =?Windows-1252?Q?FOguTmBifCndP5+nIvyoXdQUrW3mVwetYzwwYpxnxi+5Dx5PQnXeA5ad?= =?Windows-1252?Q?SfxRc8Q2xslbQ+BjEKu+7y6pgVBO0WZtGoMApelUzjUtHUOdv2k2ydE8?= =?Windows-1252?Q?TLIKEwo0KQFcyc5FQdWQdERzLxoex0rLP0/RmUKHBzW3puUe51I4SoKZ?= =?Windows-1252?Q?4hjfaSgAFT6tphE12YSatpDRp9Ay6e/LLqBM0V1fScYDAv7Esnxqm+ax?= =?Windows-1252?Q?bberYE2iFd3Ny7FZirX0l8gnv8Vr7bHIXzcEquTYOvQ01Yhpq3FRCq2W?= =?Windows-1252?Q?fpDY=3D?= X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB150;3:iABd8lTc8zfqz6J5YLc2zBopnncR2udywISbXVLJqkVszSzcyWdZa1ookhGn8+GeQ7A+i2Af7SeWj01bf/Tby1DmMgyDwpxIZHLi8KkMP6t/nWCiDT5NotYaflL4sHGKV0+uU/Beg3o+ZwHzBcB5+w==;10:GlUcKN6Def9QYCf7UABadqYSeapEjB1zdB+IxuHRsXF+dtVuk/wRyZObBuq1hqI+rrzeJ803vhiNrvHyJeaKqeJhw0LiBjJ4/k0xxM3Pv5A=;6:FIrT7QbhCodRru61XBYyQwZh1lFngkF9xq8Fek0O7tZkg8DlpJ94LJq7FQnHS8uH X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2015 16:46:07.0338 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR03MB150 X-Microsoft-Exchange-Diagnostics: 1;BLUPR03MB1345;2:GLrtiBU0vpHiNuutKN7ih7wlCyqHkUnnuwkrP3s6kIDMd8EPhHcSXRbIY8zuaRMV;2:xfCLEwoO5QhI2uN8eUPsUK4tI0v+19mHAzcwmD3KyPI7RUzOGdwGpUwYBhHQBJpsIj09OsgjL5/ivtluCMVixF6VRJKlKmybNkf5Jp3uCS4C6Ho76sitgZbjZfBRzgaD8/gFuIot2vnITBt8R4fG2w==;9:pSECeQ7w3Ra8LijxyYgSZ7Y0VbuAqYYbJzP0ICBJpGgz59Af/I7r0rwr5V6tI2oFmuSmOQwxWuwnMXXXGLrb4MLRlmJ6cgAawy3t/Ft/dmLGa+wjjmTVz976VmEeji3t3KsGQowicPG6w+ub3FpGSw== X-OriginatorOrg: freescale.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/27/2015 09:42 AM, Sebastian Hesselbarth wrote: > On 27.05.2015 17:07, York Sun wrote: >> On 05/27/2015 12:09 AM, Sebastian Hesselbarth wrote: > [...] >>> Also, why should a user ever be able to mess with the clocks? If you >>> allow a user to change the clock rate of any output, you have to >>> consider that he will likely be able to crash your system easily. >>> >>> As long as you cannot give a clear requirement for user-configurable >>> clocks - especially in the detail of the driver you mentioned - >>> mainline kernel is not the place for such a driver. >> >> This driver I am proposing supports SI5338 in a generic way. It can take device >> tree as its default configuration. However I am using it differently, explained >> in detail below. > [...] >>> (a) Clocks are limited to the PCI card and only need a limited set of >>> configurable clocks. You should add functions to load the registers >>> with either the full register map or parts of it in a table based >>> approach. You don't expose the clocks with CCF but deal with rate >>> change requests internally in the PCI driver. You could also consider >>> to have the initial clock configuration as part of some firmware blob >>> you request with the PCI driver. >> >> That's right. I only need to change a small portion of the configuration, such >> as frequency, but keeping the reset the same, including output driver voltage, >> input clock, etc. > [...] >> My application has a host SoC booting up Linux. Then the clocks on PCIe (FPGA) >> cards get initialized with their clocks. The clocks are not used by host SoC, so >> setting the wrong clocks doesn't crash the system. Each PCIe card has up to four >> clock chips (with four clocks on each chip). It is required for users to be able >> to change the clocks after system boots up. > > Consider a userspace configurable clock driver, load the FPGA design > which depends on a specific frequency generated by Si5338 and let the > user mess with your sysfs files - that will certainly crash your system. > > Still, I do not see any requirement for a clock driver for that use > case. You have to load the FPGA design or at least configure it to > use the Si5338 generated clocks _after_ configuring Si5338. You'll > have to have a user interface for FPGA bitfile loading, so you can > add another one for the clock generator config. > >> I wrote my driver for the PCIe cards so the clocks can be initialized using the >> data provided. But changing the clocks, or initializing with another set of >> configuration requires an interface. There are many ways to solve this. I would >> like to keep the clock driver generic so it can be reused. It looks like CCF may >> not be the best fit for such driver. What is an acceptable way to write this >> driver so it can be in the mainline kernel, or other maintained projects (I am >> not aware of any though)? > > IMHO "generic" as in a generic mainline kernel clock driver just means > that other _drivers_ can request any clock rate from that chip. If you > want to write a CCF driver for Si5338, you'll have to make your PCIe > driver request that clock and hide the userspace configuration within > your PCIe driver. > > Adding userspace interfaces to generic CCF clock drivers will not happen > just because messing with the clocks will break a running system. As I > said before, AFAIKS i2c-dev should give you enough of an interface to > configure the clock generator from userspace. > Sebastian, Thanks for the insight. Looks like I should give up upstreaming this driver. I will find other ways to make this driver available if anyone wants to use it. York