From patchwork Mon Feb 25 16:44:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Claudiu Beznea X-Patchwork-Id: 1047896 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=microchip.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="npokOR9S"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=microchiptechnology.onmicrosoft.com header.i=@microchiptechnology.onmicrosoft.com header.b="jzxnPxOZ"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 447SXX0FmZz9s4Z for ; Tue, 26 Feb 2019 03:47:08 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Content-ID:In-Reply-To: References:Message-ID:Date:Subject:To:From:Reply-To:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Qcm2uQxW1YZVjbJZvdPaETe/NmPMixu+F7HvN7eQ5a8=; b=npokOR9SdFBWwl pGkiyXwddw9/oLTr90MxwAuNNN0b8rnj9HfrIntW+WKOvrPUmpwamBvGae1igHq9i2RIE3dOj/40O 3GAFltxNhXCaVhW00QE9rMqrYvleWGAX+ciOHE7Fqp+WLJHw+18itvc4lhuq9QK/duue6dMrN9DpL ibWZcR5X3Uguin+ojguJauPCTKZDD+MH0xGTTMnvn2bxkzhdBqV86xCpYlZytVtwSrMADO964KNjc RH1ybvydzSYgw9pwrr3hDpuCRUZvVCcHRxWYxeq/JW9JhJQSz2CdZgVGFuxFD/6YpTczJ6w6qCZKp NbDtHKdnBoMjwmWMbZCw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gyJPC-0001dq-E8; Mon, 25 Feb 2019 16:47:02 +0000 Received: from esa4.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gyJP8-0001d2-JM for linux-arm-kernel@lists.infradead.org; Mon, 25 Feb 2019 16:47:00 +0000 X-IronPort-AV: E=Sophos;i="5.58,411,1544511600"; d="scan'208";a="26850550" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 25 Feb 2019 09:46:26 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (10.10.215.89) by email.microchip.com (10.10.76.49) with Microsoft SMTP Server (TLS) id 14.3.352.0; Mon, 25 Feb 2019 09:44:52 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microchiptechnology.onmicrosoft.com; s=selector1-microchiptechnology-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=f+mKEqtAHsmqeHMNpTNGLDKtNel51wxJhQW2dKFIUUg=; b=jzxnPxOZbhH21g26n50wJIy4SeB4OdRyw1ihmkTJkNDE2b69/u0ivFmBFxciOCyO9X9TlqGoi8z4xOimXyZSFEg+sD3E5kg/M5Mzg6hYBCCfHE7dRMo8dGj4MpPgJel+x+BV7oZ+iXB0QrkqvVUtTPomNZ9s0CXbE44ykv+plFY= Received: from MWHPR11MB1920.namprd11.prod.outlook.com (10.175.54.19) by MWHPR11MB1662.namprd11.prod.outlook.com (10.172.55.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1643.18; Mon, 25 Feb 2019 16:44:34 +0000 Received: from MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::dcd3:5ebd:191c:549e]) by MWHPR11MB1920.namprd11.prod.outlook.com ([fe80::dcd3:5ebd:191c:549e%6]) with mapi id 15.20.1643.019; Mon, 25 Feb 2019 16:44:34 +0000 From: To: , , , , , Subject: [PATCH v3 1/5] pwm: atmel: add struct atmel_pwm_data Thread-Topic: [PATCH v3 1/5] pwm: atmel: add struct atmel_pwm_data Thread-Index: AQHUzSliQ2KmCLJyZE2AEuVad3ALHQ== Date: Mon, 25 Feb 2019 16:44:33 +0000 Message-ID: <1551113039-937-2-git-send-email-claudiu.beznea@microchip.com> References: <1551113039-937-1-git-send-email-claudiu.beznea@microchip.com> In-Reply-To: <1551113039-937-1-git-send-email-claudiu.beznea@microchip.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: VI1PR0102CA0053.eurprd01.prod.exchangelabs.com (2603:10a6:803::30) To MWHPR11MB1920.namprd11.prod.outlook.com (2603:10b6:300:110::19) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Claudiu.Beznea@microchip.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.7.4 x-originating-ip: [94.177.32.154] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7c2a659d-f441-4dbd-8f49-08d69b408521 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600127)(711020)(4605104)(2017052603328)(7153060)(7193020); SRVR:MWHPR11MB1662; x-ms-traffictypediagnostic: MWHPR11MB1662: x-microsoft-exchange-diagnostics: =?utf-8?q?1=3BMWHPR11MB1662=3B23=3AYz9i?= =?utf-8?q?iF9hL9av5CpzpaYWJQoCMzf4YkChyiBflUxEIZE9u47DU6OTC+1dRMYH?= =?utf-8?q?Ef7IuYNnYG7TKNYt8P6lG8YRtok0oViw6SaH/MpiB2URa9a43EaGCJ7L?= =?utf-8?q?0Jg+rFt6iOCJGMLsEnMSZi5Fg2n1aLoTc2p0BU1ymfPMmAkmRpaKtmYO?= =?utf-8?q?ST7+gsTIYA28zwbpmOXvrLnkd8+dnPge2f+PazLJlARmZkARwqOg61Cl?= =?utf-8?q?NiFAha0j/66Lgz/+BCfwduyPWH0HVGG7XwJi0u8noqjqPt79n7STY+RF?= =?utf-8?q?+XNnF5TbGrCacJrebqZ6XMMmUtdWApW8IpIih+EypjDwXm2Rk+8N36FQ?= =?utf-8?q?AmhheZAJw5S+eu2DGcO17j8Vp5GjBD+n+xGRIUDXrLmNMC4jtiPmM9l/?= =?utf-8?q?G0KRQHhY5Kat5oRHKEScElTvOpqeOncggyWLm2yUiMUO3BodwKV5GXqB?= =?utf-8?q?paEDehVerX8YHOyL3lpw2eWmE+/Qvu0+81A8B4fd9PhE6He3lH4rzgxX?= =?utf-8?q?ypfTFI/jluNeZ5Ash9OAVbbbitIcYCR0KfF77Ax0PTECTa/q30aeHg88?= =?utf-8?q?/DAxXgz0mB44UozSIuB3LCGY5bjakfwopnO4Kf9LShs771QCkruQHHE+?= =?utf-8?q?Y7kplBPPIcv9uv0x88o2TAG4nKIzfMdgtqjQcgNLqGfbXVS7mTFi/ojF?= =?utf-8?q?tjDzp5KtTXFKXGJmcyapjWwvGKBPOhobY1k54l7U0YjFxJKWi/lZ7Vwo?= =?utf-8?q?0OwcYhTyPCYjGa4dS0tfMzm68I/CGKfqwjrHeZzdC3LM/jxAfB6Qdr5E?= =?utf-8?q?TaDpeZ7JXFQfAa2xQ8iepr5efVSSXfy2FSrdFBmSjqyMOtiDMXxzzKqT?= =?utf-8?q?xbJP3+1XurHdqsYQurLTn9yb5dIxO7FldweaUng2t0etFIWxFA7ZI1pU?= =?utf-8?q?BVXVVq41zUf/SX/1y0eEVzk7dtWGm0uR64BxXLe4UTF0NLU5Z6C/1rAl?= =?utf-8?q?bdZawdW/S4mhdMAM3q+dJ083NohTWeny+9oQYu3fjwodMBPKXhqDpe5I?= =?utf-8?q?QBK4Dh8a+ry/qpeqtILKuI6nHA7bRAKOlXjlH/LvBy4Mg+Oq5GDuodFd?= =?utf-8?q?NUXL2i/4bVAD48z/fSp4+JV369yUEf2emx8FXZr8xtL3crMRNNo/vt4r?= =?utf-8?q?QcW5T90rXdROJeSDufQOqZDBxt5FvWFjVhXjqED6szXKOKco3ciO6J0M?= =?utf-8?q?J2MirVE3Jy8JmjDApyENIH1ooyBZ4IlbzWsRifKFZkXztv0U4knSgsGV?= =?utf-8?q?7fqJxn2fQWlOl93mmbvWK0n2T2peDthfePqrgfAue+6PhA4JE1HeGc0W?= =?utf-8?q?u79TRYPh6iSUT+xXjAgScqz5mwb+6UU=3D?= x-microsoft-antispam-prvs: x-forefront-prvs: 095972DF2F x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(396003)(346002)(376002)(136003)(39860400002)(366004)(199004)(189003)(68736007)(2501003)(97736004)(5660300002)(105586002)(106356001)(66574012)(36756003)(14444005)(256004)(110136005)(54906003)(316002)(86362001)(99286004)(6636002)(52116002)(76176011)(66066001)(446003)(2616005)(476003)(72206003)(6512007)(6506007)(11346002)(386003)(6116002)(3846002)(50226002)(14454004)(478600001)(8676002)(81166006)(81156014)(486006)(8936002)(53936002)(6486002)(107886003)(305945005)(71190400001)(71200400001)(6436002)(102836004)(186003)(4326008)(25786009)(26005)(7736002)(2906002); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR11MB1662; H:MWHPR11MB1920.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: microchip.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: A5zlhL7jQt4TzWm4oCyBMPtxNUo7U5Z3uZ9Xu+OlDau463jN2Rz63iOpnzOboAYrV+RQFAXXtHUnGOhsqwgHZF2BV9unBNy+ezhlnkM4QlWFuh1wZe4R19AExh6ondrDp/2K5PsEoAKHkFxAFj8fuXcJ1yM7pmSCXM5cRJUCshoHtL++bIaPp0sxWEzlE1Z1A1OwO3Cp8A1f5XZreZL5rolVU/rjyXJgxrPSb9woi390AQNri8a46ePEUunqqs/+2GALGSbII2ptzCJKguboEx4GpcqwtUsAUaT9uyxQHfVhmbIGQ37658FkT8chgE3YruT7X+6PHEW2Fe9BRtp3uGJSjuENyX6RZshoseRBMCF7yqZcFtl02Bf4IuDaE23sXtdNMHjbksrf5gFNCkPBoV8HVBxF2Gxc+fcSLCBu0Nk= Content-ID: <2EAD1B03EC6BE242B11644AC315A7519@namprd11.prod.outlook.com> MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 7c2a659d-f441-4dbd-8f49-08d69b408521 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Feb 2019 16:44:30.6133 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-id: 3f4057f3-b418-4d4e-ba84-d55b4e897d88 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR11MB1662 X-OriginatorOrg: microchip.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190225_084658_767417_63D02498 X-CRM114-Status: GOOD ( 13.90 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [68.232.154.123 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 DKIMWL_WL_MED DKIMwl.org - Whitelisted Medium sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-pwm@vger.kernel.org, Claudiu.Beznea@microchip.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org From: Claudiu Beznea Add struct atmel_pwm_data to embed different per controller information. It prepares adding support for another similar controller that needs additional information. At this stage, embed a member of type struct atmel_pwm_registers in it. Signed-off-by: Claudiu Beznea Acked-by: Uwe Kleine-König --- drivers/pwm/pwm-atmel.c | 64 +++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c index 530d7dc5f1b5..7e86a5266eb6 100644 --- a/drivers/pwm/pwm-atmel.c +++ b/drivers/pwm/pwm-atmel.c @@ -65,11 +65,15 @@ struct atmel_pwm_registers { u8 duty_upd; }; +struct atmel_pwm_data { + struct atmel_pwm_registers regs; +}; + struct atmel_pwm_chip { struct pwm_chip chip; struct clk *clk; void __iomem *base; - const struct atmel_pwm_registers *regs; + const struct atmel_pwm_data *data; unsigned int updated_pwms; /* ISR is cleared when read, ensure only one thread does that */ @@ -150,15 +154,15 @@ static void atmel_pwm_update_cdty(struct pwm_chip *chip, struct pwm_device *pwm, struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); u32 val; - if (atmel_pwm->regs->duty_upd == - atmel_pwm->regs->period_upd) { + if (atmel_pwm->data->regs.duty_upd == + atmel_pwm->data->regs.period_upd) { val = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm, PWM_CMR); val &= ~PWM_CMR_UPD_CDTY; atmel_pwm_ch_writel(atmel_pwm, pwm->hwpwm, PWM_CMR, val); } atmel_pwm_ch_writel(atmel_pwm, pwm->hwpwm, - atmel_pwm->regs->duty_upd, cdty); + atmel_pwm->data->regs.duty_upd, cdty); } static void atmel_pwm_set_cprd_cdty(struct pwm_chip *chip, @@ -168,9 +172,9 @@ static void atmel_pwm_set_cprd_cdty(struct pwm_chip *chip, struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip); atmel_pwm_ch_writel(atmel_pwm, pwm->hwpwm, - atmel_pwm->regs->duty, cdty); + atmel_pwm->data->regs.duty, cdty); atmel_pwm_ch_writel(atmel_pwm, pwm->hwpwm, - atmel_pwm->regs->period, cprd); + atmel_pwm->data->regs.period, cprd); } static void atmel_pwm_disable(struct pwm_chip *chip, struct pwm_device *pwm, @@ -225,7 +229,7 @@ static int atmel_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm, cstate.polarity == state->polarity && cstate.period == state->period) { cprd = atmel_pwm_ch_readl(atmel_pwm, pwm->hwpwm, - atmel_pwm->regs->period); + atmel_pwm->data->regs.period); atmel_pwm_calculate_cdty(state, cprd, &cdty); atmel_pwm_update_cdty(chip, pwm, cdty); return 0; @@ -277,27 +281,31 @@ static const struct pwm_ops atmel_pwm_ops = { .owner = THIS_MODULE, }; -static const struct atmel_pwm_registers atmel_pwm_regs_v1 = { - .period = PWMV1_CPRD, - .period_upd = PWMV1_CUPD, - .duty = PWMV1_CDTY, - .duty_upd = PWMV1_CUPD, +static const struct atmel_pwm_data atmel_pwm_data_v1 = { + .regs = { + .period = PWMV1_CPRD, + .period_upd = PWMV1_CUPD, + .duty = PWMV1_CDTY, + .duty_upd = PWMV1_CUPD, + }, }; -static const struct atmel_pwm_registers atmel_pwm_regs_v2 = { - .period = PWMV2_CPRD, - .period_upd = PWMV2_CPRDUPD, - .duty = PWMV2_CDTY, - .duty_upd = PWMV2_CDTYUPD, +static const struct atmel_pwm_data atmel_pwm_data_v2 = { + .regs = { + .period = PWMV2_CPRD, + .period_upd = PWMV2_CPRDUPD, + .duty = PWMV2_CDTY, + .duty_upd = PWMV2_CDTYUPD, + }, }; static const struct platform_device_id atmel_pwm_devtypes[] = { { .name = "at91sam9rl-pwm", - .driver_data = (kernel_ulong_t)&atmel_pwm_regs_v1, + .driver_data = (kernel_ulong_t)&atmel_pwm_data_v1, }, { .name = "sama5d3-pwm", - .driver_data = (kernel_ulong_t)&atmel_pwm_regs_v2, + .driver_data = (kernel_ulong_t)&atmel_pwm_data_v2, }, { /* sentinel */ }, @@ -307,20 +315,20 @@ MODULE_DEVICE_TABLE(platform, atmel_pwm_devtypes); static const struct of_device_id atmel_pwm_dt_ids[] = { { .compatible = "atmel,at91sam9rl-pwm", - .data = &atmel_pwm_regs_v1, + .data = &atmel_pwm_data_v1, }, { .compatible = "atmel,sama5d3-pwm", - .data = &atmel_pwm_regs_v2, + .data = &atmel_pwm_data_v2, }, { .compatible = "atmel,sama5d2-pwm", - .data = &atmel_pwm_regs_v2, + .data = &atmel_pwm_data_v2, }, { /* sentinel */ }, }; MODULE_DEVICE_TABLE(of, atmel_pwm_dt_ids); -static inline const struct atmel_pwm_registers * +static inline const struct atmel_pwm_data * atmel_pwm_get_driver_data(struct platform_device *pdev) { const struct platform_device_id *id; @@ -330,18 +338,18 @@ atmel_pwm_get_driver_data(struct platform_device *pdev) id = platform_get_device_id(pdev); - return (struct atmel_pwm_registers *)id->driver_data; + return (struct atmel_pwm_data *)id->driver_data; } static int atmel_pwm_probe(struct platform_device *pdev) { - const struct atmel_pwm_registers *regs; + const struct atmel_pwm_data *data; struct atmel_pwm_chip *atmel_pwm; struct resource *res; int ret; - regs = atmel_pwm_get_driver_data(pdev); - if (!regs) + data = atmel_pwm_get_driver_data(pdev); + if (!data) return -ENODEV; atmel_pwm = devm_kzalloc(&pdev->dev, sizeof(*atmel_pwm), GFP_KERNEL); @@ -373,7 +381,7 @@ static int atmel_pwm_probe(struct platform_device *pdev) atmel_pwm->chip.base = -1; atmel_pwm->chip.npwm = 4; - atmel_pwm->regs = regs; + atmel_pwm->data = data; atmel_pwm->updated_pwms = 0; mutex_init(&atmel_pwm->isr_lock);