Re: [PATCH v2] platform/x86: Add lenovo-yoga-tab2-pro-1380-fastcharger driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 22 Apr 2024, Hans de Goede wrote:

> Add a new driver for the custom fast charging protocol found on Lenovo Yoga
> Tablet 2 1380F / 1380L models.
> 
> Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
> ---
> Changes in v2 (from review by Andy):
> - Add a couple of missing includes
> - Couple of small coding style fixes
> ---
>  drivers/platform/x86/Kconfig                  |  11 +
>  drivers/platform/x86/Makefile                 |   1 +
>  .../lenovo-yoga-tab2-pro-1380-fastcharger.c   | 337 ++++++++++++++++++
>  3 files changed, 349 insertions(+)
>  create mode 100644 drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
> 
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index cd0ec10240b6..318f2f77c97a 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -133,6 +133,17 @@ config YOGABOOK
>  	  To compile this driver as a module, choose M here: the module will
>  	  be called lenovo-yogabook.
>  
> +config YT2_1380
> +	tristate "Lenovo Yoga Tablet 2 1380 fast charge driver"
> +	depends on SERIAL_DEV_BUS
> +	depends on ACPI
> +	help
> +	  Say Y here to enable support for the custom fast charging protocol
> +	  found on the Lenovo Yoga Tablet 2 1380F / 1380L models.
> +
> +	  To compile this driver as a module, choose M here: the module will
> +	  be called lenovo-yogabook.
> +
>  config ACERHDF
>  	tristate "Acer Aspire One temperature and fan driver"
>  	depends on ACPI && THERMAL
> diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
> index 5521a87f0718..2640475a9f97 100644
> --- a/drivers/platform/x86/Makefile
> +++ b/drivers/platform/x86/Makefile
> @@ -66,6 +66,7 @@ obj-$(CONFIG_SENSORS_HDAPS)	+= hdaps.o
>  obj-$(CONFIG_THINKPAD_ACPI)	+= thinkpad_acpi.o
>  obj-$(CONFIG_THINKPAD_LMI)	+= think-lmi.o
>  obj-$(CONFIG_YOGABOOK)		+= lenovo-yogabook.o
> +obj-$(CONFIG_YT2_1380)		+= lenovo-yoga-tab2-pro-1380-fastcharger.o
>  obj-$(CONFIG_LENOVO_WMI_CAMERA)	+= lenovo-wmi-camera.o
>  
>  # Intel
> diff --git a/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c b/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
> new file mode 100644
> index 000000000000..035d8cc86079
> --- /dev/null
> +++ b/drivers/platform/x86/lenovo-yoga-tab2-pro-1380-fastcharger.c
> @@ -0,0 +1,337 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Support for the custom fast charging protocol found on the Lenovo Yoga
> + * Tablet 2 1380F / 1380L models.
> + *
> + * Copyright (C) 2024 Hans de Goede <hansg@xxxxxxxxxx>
> + */
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
> +#include <linux/delay.h>
> +#include <linux/err.h>
> +#include <linux/errno.h>
> +#include <linux/extcon.h>
> +#include <linux/gpio/consumer.h>
> +#include <linux/module.h>
> +#include <linux/notifier.h>
> +#include <linux/pinctrl/consumer.h>
> +#include <linux/pinctrl/machine.h>
> +#include <linux/platform_device.h>
> +#include <linux/serdev.h>
> +#include <linux/types.h>
> +#include <linux/workqueue.h>
> +#include "serdev_helpers.h"
> +
> +#define YT2_1380_FC_PDEV_NAME		"lenovo-yoga-tab2-pro-1380-fastcharger"
> +#define YT2_1380_FC_SERDEV_CTRL		"serial0"
> +#define YT2_1380_FC_SERDEV_NAME		"serial0-0"
> +#define YT2_1380_FC_EXTCON_NAME		"i2c-lc824206xa"
> +
> +#define YT2_1380_FC_MAX_TRIES		5
> +#define YT2_1380_FC_PIN_SW_DELAY_US	(10 * USEC_PER_MSEC)
> +#define YT2_1380_FC_UART_DRAIN_DELAY_US	(50 * USEC_PER_MSEC)
> +#define YT2_1380_FC_VOLT_SW_DELAY_US	(1000 * USEC_PER_MSEC)

Add include for *SEC_PER_*SEC.

Once that's taken care of,

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@xxxxxxxxxxxxxxx>

-- 
 i.

[Index of Archives]     [Linux Kernel Development]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux