From patchwork Mon Jun 22 10:03:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Sm9obnNvbiBDSCBDaGVuICjpmbPmmK3li7Mp?= X-Patchwork-Id: 11617399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7198D60D for ; Mon, 22 Jun 2020 10:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 556E82071A for ; Mon, 22 Jun 2020 10:03:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=moxa.com header.i=@moxa.com header.b="PQoB7WjT" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728118AbgFVKDf (ORCPT ); Mon, 22 Jun 2020 06:03:35 -0400 Received: from mail-eopbgr1320044.outbound.protection.outlook.com ([40.107.132.44]:38144 "EHLO APC01-PU1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726898AbgFVKDd (ORCPT ); Mon, 22 Jun 2020 06:03:33 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mfG8SlCVPhzsIVUjZfpjzfzHigS8pT6aws5OFOr1oTBUf2x6Kb/TJ8mPoWgIiGPLSIR/0y/lGKbtUDa2nkv33yUoesDldmXuts04vuLzzio24D7uQdUapGy1A1jhubMwYYm3ggOkgy88DCEa4sMEUp44sJRnFpihodp9Gmjfc2qym8Bbr+WMkGk3lneyylumKoKyQ890arv/oFhE8jeFSWt0X+n2XUNQgUSKT2PBeFE1KVnAMXGm7eLFvJg3/j9UUF6uh6JMgtp2lzSPLfo5K9UPtBQMqqiJSFT83wJsKzqU9b9E2JzJGUsvWWbPAMPfEkEJw9h23XWZyyA5kvlP1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YRVd2eUuzMtB+96qfIGRAkQjXSg15Wl8LXHYRc8Unss=; b=DRC/RY2uXylti4ESjnLEvXho0vdwd4tuO1ooArehGBBFoce0vQi2Wfx83u5DKXguq958DlbhcvR4VE0hNxnfAvSEyAnZvLIlI8S3vU35mhxsDFnL+ecds9kqmCbtRnC0zI5SU50ihRPQHGOV2YtVlVKWmYnIk9YYhQG4ptzm9LGYpS3LDoITlcXxCjJZLn3yzIgRpIBEetUEJdv+02DgtUsBYXqPqwzPRDb1E/d+cGTAScl6IffxvuXJp7vlrWWGcI0cc873Bg9Fl+P3M6EsIs5QShRu/oCSoadNcoUn7KT0YFkNtq3Vh8mhh3AYoBk4zHt0ufSvnF8slJnVDWIvnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=moxa.com; dmarc=pass action=none header.from=moxa.com; dkim=pass header.d=moxa.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=moxa.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YRVd2eUuzMtB+96qfIGRAkQjXSg15Wl8LXHYRc8Unss=; b=PQoB7WjTgBtsRG3zV47WpK6rpyS3/hdJEK2zZ+GjWmmdwf/xCSYkhV+mt8OOIBzw30M+IeGiQav/TsfxQH5iYON+EaBpCM0k/h0KzFyy1jihEYyXgeAErOEfjga+Ig+P3sIl6ZRB5fvlXhUZX3/I12rBw1WJZAvqKikwymccGcI= Received: from HK2PR01MB3281.apcprd01.prod.exchangelabs.com (2603:1096:202:22::12) by HK2PR01MB3217.apcprd01.prod.exchangelabs.com (2603:1096:202:24::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 10:03:27 +0000 Received: from HK2PR01MB3281.apcprd01.prod.exchangelabs.com ([fe80::712b:170d:f873:68a3]) by HK2PR01MB3281.apcprd01.prod.exchangelabs.com ([fe80::712b:170d:f873:68a3%6]) with mapi id 15.20.3109.027; Mon, 22 Jun 2020 10:03:27 +0000 From: =?big5_tw?b?Sm9obnNvbiBDSCBDaGVuICizr6xMvrEp?= To: "linux-kernel@vger.kernel.org" CC: "linux-rtc@vger.kernel.org" , "linux-watchdog@vger.kernel.org" , Alessandro Zummo , Alexandre Belloni , Wim Van Sebroeck , "linux@roeck-us.net" , Lee Jones Subject: [PATCH 1/3] mfd: ds1374: Introduce Dallas/Maxim DS1374 MFD core driver Thread-Topic: [PATCH 1/3] mfd: ds1374: Introduce Dallas/Maxim DS1374 MFD core driver Thread-Index: AQHWSHlxmpPaA0sQIkC/QuBIC/9aPw== Date: Mon, 22 Jun 2020 10:03:27 +0000 Message-ID: Accept-Language: zh-TW, en-US Content-Language: zh-TW X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=moxa.com; x-originating-ip: [123.51.145.16] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e7845bb2-10b9-42f2-6302-08d816938237 x-ms-traffictypediagnostic: HK2PR01MB3217: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5236; x-forefront-prvs: 0442E569BC x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: M6m7K9wn6nbD9Ev0E1+afhFmqJ+1juZBy6OT7Kaf3Ihp0AYBANBIFfoWn9GL+17c9OB2BlFkqlrSymMe80xhoT2fgjnj5jp0c+6HefPmXyBwhLrdGpBfwQI+rGpGxHNjRfYh0adrkHA+IGqkhfyDLx9VNkaPQM0XqTXW2QRQCK2fMTlKOhdc9f+kLsMoWajzBhcR018nbipT2XFDpP0Jz/qZ1RH1pYbbk2d5hkUFzvxgFRAbpXVSdkuHBDJ07QDFRFOuT8eIFj7fe/kCqb0NYsLdvc4ouo+Ad0lvJ6NU5gZZxxGW8RheyFx0ric3RieWhr4HiYOIYycinnRDgz/48Q== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:HK2PR01MB3281.apcprd01.prod.exchangelabs.com;PTR:;CAT:NONE;SFTY:;SFS:(4636009)(136003)(366004)(346002)(396003)(376002)(39850400004)(186003)(85182001)(6506007)(26005)(8936002)(6916009)(7696005)(8676002)(71200400001)(4326008)(83380400001)(316002)(2906002)(86362001)(33656002)(52536014)(9686003)(66946007)(76116006)(64756008)(55016002)(54906003)(5660300002)(478600001)(66446008)(66556008)(66476007);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata: OWPyVmRYqOsF3pcLAjHhu4Mmx59L6qSzbIukG3IKvX5bftu+WsdQgyfhVRoe9D4kXMUCAKPhxJpEh8shHjE4oHo8wHFmZ9AnLQ3+OYOr1c7oylqMuubmCwscRFcy9uD8j6T8xx86BmMfl8P3vfNNRH3DzxRvAk4jUbs8DWyphX3vJbiuDtoE97zBWgCTQofRjei6CBshtks6pSaRqeMqS+qxCm1tYj8yr4KsMdNUFPKNzripndXlv6YR/jMIlCmNlEXaZM7PuDm2BZrvEIp5GqLz3GqNKQC6140oSF7TnEL/OgT5oOML4N23JoaXIDj6idxbA3y1xjMDK3X3AK6LnuW2/P2WoPCCrkW8ROSuOfdmk7r3lXHlWsEry8mPgoTAKhMAshNK7CJptLo4wV0sRyCCCAty0BRf+AQ/67sR4lHRV87D5304t+Ldi7oKNOdg4zPjZ9JWZ4JyuTYjDK6/cVxK1fD8jK+yAx1uW2iNwfI= x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: moxa.com X-MS-Exchange-CrossTenant-Network-Message-Id: e7845bb2-10b9-42f2-6302-08d816938237 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Jun 2020 10:03:27.1967 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 5571c7d4-286b-47f6-9dd5-0aa688773c8e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GWhYuFitC/YwWEvIVaLm0TZxPYiaA85rMPbvQDZong6NavTLpuLsLyQzYYMcjm/l3R9zNDJHWcojzYR2ZyjN4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR01MB3217 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Dallas/Maxim DS1374 is a counter designed to continuously count time in seconds. It provides an I2C interface to the host to access RTC clock or Alarm/Watchdog timer. Add MFD Core driver, supporting the I2C communication to RTC and Watchdog devices. Signed-off-by: Johnson Chen Reported-by: kernel test robot --- drivers/mfd/Kconfig | 11 +++++ drivers/mfd/Makefile | 2 + drivers/mfd/ds1374.c | 101 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) create mode 100644 drivers/mfd/ds1374.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 687e9c848053..d16031f4b487 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -1980,6 +1980,17 @@ config MFD_STM32_LPTIMER To compile this driver as a module, choose M here: the module will be called stm32-lptimer. +config MFD_DS1374 + tristate "Support for Dallas/Maxim DS1374" + depends on I2C + select MFD_CORE + help + Say yes here to add support for Dallas/Maxim DS1374 Semiconductor. + This driver provides RTC and watchdog. + + This driver can also be built as a module. If so, module will be + called ds1374. + config MFD_STM32_TIMERS tristate "Support for STM32 Timers" depends on (ARCH_STM32 && OF) || COMPILE_TEST diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index bea2be419822..a6463dd4aa33 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -243,6 +243,8 @@ obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o obj-$(CONFIG_INTEL_SOC_PMIC_CHTDC_TI) += intel_soc_pmic_chtdc_ti.o mt6397-objs := mt6397-core.o mt6397-irq.o obj-$(CONFIG_MFD_MT6397) += mt6397.o +obj-$(CONFIG_MFD_DS1374) += ds1374.o + obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD) += intel_soc_pmic_mrfld.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/ds1374.c b/drivers/mfd/ds1374.c new file mode 100644 index 000000000000..6e9041aba5d2 --- /dev/null +++ b/drivers/mfd/ds1374.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Mamim/Dallas DS1374 MFD Core Driver. + * + * Copyright (C) 2020 Johnson Chen + */ + +#include +#include +#include +#include +#include + + +static struct mfd_cell ds1374_cell[] = { + { .name = "ds1374_rtc", }, + { .name = "ds1374_wdt", }, +}; + +static int ds1374_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + int ret; + + ret = i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_BYTE_DATA | + I2C_FUNC_SMBUS_WORD_DATA | + I2C_FUNC_SMBUS_BYTE); + if (!ret) + return -ENODEV; + + ret = devm_mfd_add_devices(&client->dev, 0, ds1374_cell, + ARRAY_SIZE(ds1374_cell), NULL, 0, NULL); + + if (ret < 0) { + dev_err(&client->dev, "failed to add DS1374 sub-devices\n"); + return ret; + } + + return 0; +} + +static int ds1374_remove(struct i2c_client *client) +{ + mfd_remove_devices(&client->dev); + + return 0; +} + +#ifdef CONFIG_PM_SLEEP +static int ds1374_suspend(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + if (client->irq > 0 && device_may_wakeup(&client->dev)) + enable_irq_wake(client->irq); + return 0; +} + +static int ds1374_resume(struct device *dev) +{ + struct i2c_client *client = to_i2c_client(dev); + + if (client->irq > 0 && device_may_wakeup(&client->dev)) + disable_irq_wake(client->irq); + return 0; +} +#endif + +static const struct i2c_device_id ds1374_id[] = { + { "ds1374", 0 }, + { } +}; +MODULE_DEVICE_TABLE(i2c, ds1374_id); + +#ifdef CONFIG_OF +static const struct of_device_id ds1374_of_match[] = { + { .compatible = "dallas,ds1374" }, + { } +}; +MODULE_DEVICE_TABLE(of, ds1374_of_match); +#endif + +static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); + +static struct i2c_driver ds1374_driver = { + .driver = { + .name = "ds1374", + .of_match_table = of_match_ptr(ds1374_of_match), + .pm = &ds1374_pm, + }, + .probe = ds1374_probe, + .remove = ds1374_remove, + .id_table = ds1374_id, +}; + +module_i2c_driver(ds1374_driver); + +MODULE_DESCRIPTION("Dallas/Maxim DS1374 MFD Core Driver"); +MODULE_AUTHOR("Johnson Chen "); +MODULE_LICENSE("GPL");