2020-08-17 10:10:33 +03:00
// SPDX-License-Identifier: GPL-2.0
2021-01-29 22:51:55 +03:00
/*
* Device driver for regulators in HISI PMIC IC
*
* Copyright ( c ) 2013 Linaro Ltd .
* Copyright ( c ) 2011 Hisilicon .
2021-07-17 12:58:14 +03:00
* Copyright ( c ) 2020 - 2021 Huawei Technologies Co . , Ltd .
2021-01-29 22:51:55 +03:00
*/
2020-08-17 10:10:30 +03:00
2020-08-17 10:10:35 +03:00
# include <linux/mfd/core.h>
2020-08-17 10:10:41 +03:00
# include <linux/module.h>
# include <linux/platform_device.h>
2021-07-17 12:58:15 +03:00
# include <linux/regmap.h>
2020-08-17 10:10:41 +03:00
# include <linux/slab.h>
2020-08-17 10:10:30 +03:00
# include <linux/spmi.h>
2020-08-17 10:10:35 +03:00
static const struct mfd_cell hi6421v600_devs [ ] = {
2021-07-17 12:58:15 +03:00
{ . name = " hi6421v600-irq " , } ,
2020-08-17 10:10:35 +03:00
{ . name = " hi6421v600-regulator " , } ,
2020-08-17 10:10:30 +03:00
} ;
2021-01-29 22:51:50 +03:00
static const struct regmap_config regmap_config = {
2021-06-25 10:46:00 +03:00
. reg_bits = 16 ,
. val_bits = BITS_PER_BYTE ,
. max_register = 0xffff ,
. fast_io = true
2021-01-29 22:51:47 +03:00
} ;
2021-07-17 12:58:12 +03:00
static int hi6421_spmi_pmic_probe ( struct spmi_device * sdev )
2020-08-17 10:10:30 +03:00
{
2021-07-17 12:58:12 +03:00
struct device * dev = & sdev - > dev ;
2021-09-02 15:47:48 +03:00
struct regmap * regmap ;
2021-07-17 12:58:15 +03:00
int ret ;
2020-08-17 10:10:30 +03:00
2021-09-02 15:47:48 +03:00
regmap = devm_regmap_init_spmi_ext ( sdev , & regmap_config ) ;
if ( IS_ERR ( regmap ) )
return PTR_ERR ( regmap ) ;
2021-01-29 22:51:47 +03:00
2021-09-02 15:47:48 +03:00
dev_set_drvdata ( & sdev - > dev , regmap ) ;
2020-08-17 10:10:35 +03:00
2021-07-17 12:58:12 +03:00
ret = devm_mfd_add_devices ( & sdev - > dev , PLATFORM_DEVID_NONE ,
2020-08-17 10:10:35 +03:00
hi6421v600_devs , ARRAY_SIZE ( hi6421v600_devs ) ,
NULL , 0 , NULL ) ;
2021-01-29 22:51:50 +03:00
if ( ret < 0 )
dev_err ( dev , " Failed to add child devices: %d \n " , ret ) ;
2020-08-17 10:10:41 +03:00
2020-08-17 10:10:30 +03:00
return ret ;
}
2020-08-17 10:10:35 +03:00
static const struct of_device_id pmic_spmi_id_table [ ] = {
2020-08-18 17:58:56 +03:00
{ . compatible = " hisilicon,hi6421-spmi " } ,
2020-08-17 10:10:35 +03:00
{ }
} ;
MODULE_DEVICE_TABLE ( of , pmic_spmi_id_table ) ;
2020-08-17 10:10:30 +03:00
2020-08-17 10:10:38 +03:00
static struct spmi_driver hi6421_spmi_pmic_driver = {
2020-08-17 10:10:30 +03:00
. driver = {
2020-08-17 10:10:35 +03:00
. name = " hi6421-spmi-pmic " ,
. of_match_table = pmic_spmi_id_table ,
2020-08-17 10:10:30 +03:00
} ,
2020-08-17 10:10:38 +03:00
. probe = hi6421_spmi_pmic_probe ,
2020-08-17 10:10:30 +03:00
} ;
2020-08-17 10:10:38 +03:00
module_spmi_driver ( hi6421_spmi_pmic_driver ) ;
2020-08-17 10:10:30 +03:00
2020-08-17 10:10:35 +03:00
MODULE_DESCRIPTION ( " HiSilicon Hi6421v600 SPMI PMIC driver " ) ;
2020-08-17 10:10:30 +03:00
MODULE_LICENSE ( " GPL v2 " ) ;