Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752475AbbHRGbX (ORCPT ); Tue, 18 Aug 2015 02:31:23 -0400 Received: from mail-by2on0142.outbound.protection.outlook.com ([207.46.100.142]:9847 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751243AbbHRGbU (ORCPT ); Tue, 18 Aug 2015 02:31:20 -0400 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=freescale.com; vger.kernel.org; dkim=none (message not signed) header.d=none; Date: Tue, 18 Aug 2015 13:20:12 +0800 From: Peter Chen To: Mark Brown CC: Baolin Wang , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v2 3/3] power: wm831x_power: Support USB charger current limit management Message-ID: <20150818052011.GF1864@shlinux2> References: <20150817010707.GC1864@shlinux2> <20150817172623.GO10748@sirena.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150817172623.GO10748@sirena.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD052;1:EkbKvuBZHP4NEZJ7OrmJVmjWYy8xO9ZVk//0Sim4XavlCSA9KCD1J187VtAn7gJPJEZlDLcTn+94mZanmNj4+WNYgzzCHiv8nLrPySXN8Hpe8KWiLj2BlFRrRW0LLouCMwhQQtfnqvyFfZzW/nGhHyLVaeQX3eVximmvTmK/419pqyFekZGv+ze/Y59NwZkt/i3gW6gfOwmT4dg9jsOZI9cgl2ilStrb7gOsbdMpNvfDpU33Mp6D6zdKxi1cW3buaLLXf4OI8gPpnVB4iP+pHEYJXpvdYTn0yOa/3Wug2gcKk4Z9SOa2HEJbDdyD0gF6GRcfK1ApFSAwq+NyR2JaYCMDn9eSVD1uP08T9NHW6pharXeahVkUR8pzVt2gS/UaK2MtLrkI01uVC058P1wwlg== X-Forefront-Antispam-Report: CIP:192.88.158.2;CTRY:US;IPV:NLI;EFV:NLI;SFV:NSPM;SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(189002)(199003)(24454002)(83506001)(85426001)(54356999)(93886004)(97756001)(6806004)(87936001)(76176999)(104016003)(50466002)(69596002)(33716001)(47776003)(46102003)(86362001)(46406003)(64706001)(189998001)(5001960100002)(110136002)(50986999)(105606002)(92566002)(106466001)(5001860100001)(23726002)(68736005)(2950100001)(33656002)(77096005)(97736004)(81156007)(77156002)(4001350100001)(5001830100001)(62966003)(4001540100001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0301MB1274;H:az84smr01.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1274;2:Th5zrFX2L8JluTFx/mH2Uff86oORn3HuPzpRM3lk3w6LN2zcq3ENGAIKWZoZj6GXYc0utXkcaVDELgAbDaFPrnmOvFhQkr4NDmLekLVlDjnepmSwAdz8MNKUbzrHkI3Asy/+GqzkH8xVQSchPEnLQuhUnswDl08jO9WpdeskxP8=;3:J4kqQQ1wEL8ZjXAgIybSzKLth0P6qiZxC7Yh0Ka3Tm3tJe0pVLd3nu6qTlmMvx2AJxw2ZUa2U/lE7S4QCG9andR1/rk8c5GDHDDNMwZ+9r5IbN9S3hiqiTBRcxmiFpNHhpxGs80LjrAjZ0mtD8irV4EZF8Zl7GytsHWtIGMGPWOAEkMZ7hx9O3JaG785TMkpaX9RXlGJwl/160FcyV7OYwMfp/S6UrNebpZfEAlNTFs=;25:pv5tyY847QnHCqEUaW9stpid762dQoeBfRP202n9Mn5I6usf8qsCWTnFrFPeyq/b3UyROkg8GIX38SIepdGxdneVgi45adzL1RjoqHn4VG1s/EAEuyIFXypS7o3VIuZF2QXMOnVI3lFVLh7HOMjOszdS5Gs1eDdaxFgg9O3n8EmECeeoxwAXJXSHV4onsPOQ0Vs1alhYnUaVGcGABxxLxguTaKfbDFcJw2Ivv3dtAlCSUz7ZmD3kopKP73xvi9PoLb0ULNA9IiO3LGf3h9W+aQ== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1274; X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1274;20:hg7qFeYJxQ8KhSpZlFf4d8sAwTu+hZUJXdk6kiXarPsXVpuaK4Nt7ojLTqn2LwfUKhelrMJ85tmMjLkBNjtSWND5UEy0xMevXteMdwiVPVUIJPy8iKV9F4TahaSq15SAAYIR3xXek/gq6KxaNzTGwFhbn0Uv7mFBLpXepFquYyOxkWEuuPH/Mn3Ggkl5nMyXb0V3gk9B0m/hh5Xi1GJKnXKpQL+Yrw92d1tAJQ2ga3wL5JUlWxOcChIYfYXGcwJQAKDn+YAIU7FIqO6ZSZYE/wRDkDP/4iVrACdjKMoWmXuqlqFFGl4RJJSMtlUgkBL0s7xBccrcTg6CJ2RbkGvJP0LpsE7yqf5WCgFiqi18mKs=;4:BEqczKSSjhCwPzZSQ4ck8nuGb6gcPa44w1quy3jYDFEpanI661/2R8XM3pfTYUFFT9rl/26POlUYFSSUTtWQ6WKv2/BdLx8BJ4StoHnr6MSjWu1QDZ3J7aczpTyRysGk+M8D5D+b/fxQDTsTuHXvX5Z9SJQqNFdxD7XaHDUNx8KMPI2FfTWD9blJ9A7TAyqyLGDQfAuNsTsxQBBhHkA2PTFr0mvv24Qr9Qdp/LHKF4xgzPt526h/dn6jTZXrN+Nz9NpnV8VWt3DLq7ZWuXE4eWY/8etBR/wmUIf2nWGVH3TS25erPbI9dsxClbO6hV1C X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(8121501046)(5005006)(3002001);SRVR:CY1PR0301MB1274;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1274; X-Forefront-PRVS: 067270ECAF X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q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PPt01MrVSY?= =?us-ascii?Q?EmaXnxkGDL1FxhBkx+6jSxZ8jpaqEGKOqJSgS3U6uzEsjWRKOyrn/3iH1n5y?= =?us-ascii?Q?PIlulVTtq/v9BPERdFAV4qOTFiCLHe3YsifXuqqR5UNzQeiBmAZVIApPp4q5?= =?us-ascii?Q?JxTAJt+qgfL2ux2FzBZd2zERwmTilPrSB60T0onmYLnSThfRge/eIM+SPEwb?= =?us-ascii?Q?HFXcOb8+kz52gZ1feeMowbSO7JwMxgY04ItDvhE8PtiRhagM5iH2E9Z3bfkR?= =?us-ascii?Q?BJTyqGL5xtq9wzAW4/EDkkPUVlNrmFIl5X1lDfCcuwyPKCVoVbJZwAg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;CY1PR0301MB1274;5:kUeuQuPfu2Tq2wWpx6jkiqEMTysc7R5TvBjr0m5wsWl89SF1lKLCImQa8whQ4idQPea8Vo72kHCvcKAVo6+kaqXiup/mpKkppBOUPwPVLSt0DSFS3C4ANFWT4ZxScZ4FuQGa653BntvxeGzaBYqMtg==;24:y9Kw1J6SXbuPZllfo1dR53fkwN20r34PAdrHK9PocKRSiwDURzq8jGmqKrx2N1iRejPqKuSMtqAEi+CUg1kmkfocY+JhPQQIK9QLzrOoPEA=;20:UdnW9StAv7SYdmaQ1EYPP1rISGz9EdOUN6Qo5NxoqUKJRMF9ZJ/ExD7Amwfbcd0knaee8ZrGxqIlNlrZaQnKBQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Aug 2015 06:31:17.1520 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d;Ip=[192.88.158.2];Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1274 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2435 Lines: 80 On Mon, Aug 17, 2015 at 10:26:23AM -0700, Mark Brown wrote: > On Mon, Aug 17, 2015 at 09:07:08AM +0800, Peter Chen wrote: > > On Fri, Aug 14, 2015 at 05:47:46PM +0800, Baolin Wang wrote: > > > > + 1500, > > > + 1800, > > > + 550, > > > +}; > > > Why 550 is the last, but not 1800? > > You'd have to ask the hardware engineers who designed the chip. I > suspect it's because 550 was added at a late stage in the design process > but I'm basically just guessing there. ok, I just had suspected below function's correctness, after looking it again, it always set 1800 as charging limit, does it be expected? +/* In miliamps */ +static unsigned int wm831x_usb_limits[] = { + 0, + 2, + 100, + 500, + 900, + 1500, + 1800, + 550, +}; + +static int wm831x_usb_limit_change(struct notifier_block *nb, + unsigned long limit, void *data) +{ + struct wm831x_power *wm831x_power = container_of(nb, + struct wm831x_power, + usb_notify); + int i, best; + + /* Find the highest supported limit */ + best = 0; + for (i = 0; i < ARRAY_SIZE(wm831x_usb_limits); i++) { + if (limit < wm831x_usb_limits[i] && + wm831x_usb_limits[best] < wm831x_usb_limits[i]) + best = i; + } + + dev_dbg(wm831x_power->wm831x->dev, + "Limiting USB current to %dmA", wm831x_usb_limits[best]); + + wm831x_set_bits(wm831x_power->wm831x, WM831X_POWER_STATE, + WM831X_USB_ILIM_MASK, best); + + return 0; +} + > > > > *********************************************************************/ > > > @@ -606,8 +646,31 @@ static int wm831x_power_probe(struct platform_device *pdev) > > > } > > > } > > > > + if (wm831x_pdata && wm831x_pdata->usb_gadget) { > > > Where the wm831x_pdata->usb_gadget is initialized? > > It's platform data, it will be initialised by whatever registers the > platform data. Get it, I just do not find in this patch set, thanks. -- Best Regards, Peter Chen -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/