rk818-charger: dont ship clk-rk808, rk808-regulator, rk8xx-spi since the mainline versions work fine
This commit is contained in:
@@ -1,12 +1,9 @@
|
||||
obj-m := clk-rk808.o rk808-regulator.o rk818_battery.o rk818_charger.o rk8xx-core.o rk8xx-i2c.o rk8xx-spi.o
|
||||
obj-m := rk818_battery.o rk818_charger.o rk8xx-core.o rk8xx-i2c.o
|
||||
|
||||
all:
|
||||
$(MAKE) -C "$(KERNEL_DIR)" M="$(PWD)" modules
|
||||
install:
|
||||
install -Dm444 clk-rk808.ko $(INSTALL_MOD_PATH)/drivers/clk/clk-rk808.ko
|
||||
install -Dm444 rk808-regulator.ko $(INSTALL_MOD_PATH)/drivers/regulator/rk808-regulator.ko
|
||||
install -Dm444 rk818_battery.ko $(INSTALL_MOD_PATH)/drivers/power/supply/rk818_battery.ko
|
||||
install -Dm444 rk818_charger.ko $(INSTALL_MOD_PATH)/drivers/power/supply/rk818_charger.ko
|
||||
install -Dm444 rk8xx-core.ko $(INSTALL_MOD_PATH)/drivers/mfd/rk8xx-core.ko
|
||||
install -Dm444 rk8xx-i2c.ko $(INSTALL_MOD_PATH)/drivers/mfd/rk8xx-i2c.ko
|
||||
install -Dm444 rk8xx-spi.ko $(INSTALL_MOD_PATH)/drivers/mfd/rk8xx-spi.ko
|
||||
|
@@ -1,209 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Clkout driver for Rockchip RK808
|
||||
*
|
||||
* Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
|
||||
*
|
||||
* Author:Chris Zhong <zyw@rock-chips.com>
|
||||
*/
|
||||
|
||||
#include <linux/clk-provider.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/mfd/rk808.h>
|
||||
|
||||
struct rk808_clkout {
|
||||
struct regmap *regmap;
|
||||
struct clk_hw clkout1_hw;
|
||||
struct clk_hw clkout2_hw;
|
||||
};
|
||||
|
||||
static unsigned long rk808_clkout_recalc_rate(struct clk_hw *hw,
|
||||
unsigned long parent_rate)
|
||||
{
|
||||
return 32768;
|
||||
}
|
||||
|
||||
static int rk808_clkout2_enable(struct clk_hw *hw, bool enable)
|
||||
{
|
||||
struct rk808_clkout *rk808_clkout = container_of(hw,
|
||||
struct rk808_clkout,
|
||||
clkout2_hw);
|
||||
|
||||
return regmap_update_bits(rk808_clkout->regmap, RK808_CLK32OUT_REG,
|
||||
CLK32KOUT2_EN, enable ? CLK32KOUT2_EN : 0);
|
||||
}
|
||||
|
||||
static int rk808_clkout2_prepare(struct clk_hw *hw)
|
||||
{
|
||||
return rk808_clkout2_enable(hw, true);
|
||||
}
|
||||
|
||||
static void rk808_clkout2_unprepare(struct clk_hw *hw)
|
||||
{
|
||||
rk808_clkout2_enable(hw, false);
|
||||
}
|
||||
|
||||
static int rk808_clkout2_is_prepared(struct clk_hw *hw)
|
||||
{
|
||||
struct rk808_clkout *rk808_clkout = container_of(hw,
|
||||
struct rk808_clkout,
|
||||
clkout2_hw);
|
||||
uint32_t val;
|
||||
|
||||
int ret = regmap_read(rk808_clkout->regmap, RK808_CLK32OUT_REG, &val);
|
||||
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return (val & CLK32KOUT2_EN) ? 1 : 0;
|
||||
}
|
||||
|
||||
static const struct clk_ops rk808_clkout1_ops = {
|
||||
.recalc_rate = rk808_clkout_recalc_rate,
|
||||
};
|
||||
|
||||
static const struct clk_ops rk808_clkout2_ops = {
|
||||
.prepare = rk808_clkout2_prepare,
|
||||
.unprepare = rk808_clkout2_unprepare,
|
||||
.is_prepared = rk808_clkout2_is_prepared,
|
||||
.recalc_rate = rk808_clkout_recalc_rate,
|
||||
};
|
||||
|
||||
static struct clk_hw *
|
||||
of_clk_rk808_get(struct of_phandle_args *clkspec, void *data)
|
||||
{
|
||||
struct rk808_clkout *rk808_clkout = data;
|
||||
unsigned int idx = clkspec->args[0];
|
||||
|
||||
if (idx >= 2) {
|
||||
pr_err("%s: invalid index %u\n", __func__, idx);
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
return idx ? &rk808_clkout->clkout2_hw : &rk808_clkout->clkout1_hw;
|
||||
}
|
||||
|
||||
static int rk817_clkout2_enable(struct clk_hw *hw, bool enable)
|
||||
{
|
||||
struct rk808_clkout *rk808_clkout = container_of(hw,
|
||||
struct rk808_clkout,
|
||||
clkout2_hw);
|
||||
|
||||
return regmap_update_bits(rk808_clkout->regmap, RK817_SYS_CFG(1),
|
||||
RK817_CLK32KOUT2_EN,
|
||||
enable ? RK817_CLK32KOUT2_EN : 0);
|
||||
}
|
||||
|
||||
static int rk817_clkout2_prepare(struct clk_hw *hw)
|
||||
{
|
||||
return rk817_clkout2_enable(hw, true);
|
||||
}
|
||||
|
||||
static void rk817_clkout2_unprepare(struct clk_hw *hw)
|
||||
{
|
||||
rk817_clkout2_enable(hw, false);
|
||||
}
|
||||
|
||||
static int rk817_clkout2_is_prepared(struct clk_hw *hw)
|
||||
{
|
||||
struct rk808_clkout *rk808_clkout = container_of(hw,
|
||||
struct rk808_clkout,
|
||||
clkout2_hw);
|
||||
unsigned int val;
|
||||
|
||||
int ret = regmap_read(rk808_clkout->regmap, RK817_SYS_CFG(1), &val);
|
||||
|
||||
if (ret < 0)
|
||||
return 0;
|
||||
|
||||
return (val & RK817_CLK32KOUT2_EN) ? 1 : 0;
|
||||
}
|
||||
|
||||
static const struct clk_ops rk817_clkout2_ops = {
|
||||
.prepare = rk817_clkout2_prepare,
|
||||
.unprepare = rk817_clkout2_unprepare,
|
||||
.is_prepared = rk817_clkout2_is_prepared,
|
||||
.recalc_rate = rk808_clkout_recalc_rate,
|
||||
};
|
||||
|
||||
static const struct clk_ops *rkpmic_get_ops(long variant)
|
||||
{
|
||||
switch (variant) {
|
||||
case RK809_ID:
|
||||
case RK817_ID:
|
||||
return &rk817_clkout2_ops;
|
||||
/*
|
||||
* For the default case, it match the following PMIC type.
|
||||
* RK805_ID
|
||||
* RK808_ID
|
||||
* RK818_ID
|
||||
*/
|
||||
default:
|
||||
return &rk808_clkout2_ops;
|
||||
}
|
||||
}
|
||||
|
||||
static int rk808_clkout_probe(struct platform_device *pdev)
|
||||
{
|
||||
struct rk808 *rk808 = dev_get_drvdata(pdev->dev.parent);
|
||||
struct device *dev = &pdev->dev;
|
||||
struct clk_init_data init = {};
|
||||
struct rk808_clkout *rk808_clkout;
|
||||
int ret;
|
||||
|
||||
dev->of_node = pdev->dev.parent->of_node;
|
||||
|
||||
rk808_clkout = devm_kzalloc(dev,
|
||||
sizeof(*rk808_clkout), GFP_KERNEL);
|
||||
if (!rk808_clkout)
|
||||
return -ENOMEM;
|
||||
|
||||
rk808_clkout->regmap = dev_get_regmap(pdev->dev.parent, NULL);
|
||||
if (!rk808_clkout->regmap)
|
||||
return -ENODEV;
|
||||
|
||||
init.parent_names = NULL;
|
||||
init.num_parents = 0;
|
||||
init.name = "rk808-clkout1";
|
||||
init.ops = &rk808_clkout1_ops;
|
||||
rk808_clkout->clkout1_hw.init = &init;
|
||||
|
||||
/* optional override of the clockname */
|
||||
of_property_read_string_index(dev->of_node, "clock-output-names",
|
||||
0, &init.name);
|
||||
|
||||
ret = devm_clk_hw_register(dev, &rk808_clkout->clkout1_hw);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
init.name = "rk808-clkout2";
|
||||
init.ops = rkpmic_get_ops(rk808->variant);
|
||||
rk808_clkout->clkout2_hw.init = &init;
|
||||
|
||||
/* optional override of the clockname */
|
||||
of_property_read_string_index(dev->of_node, "clock-output-names",
|
||||
1, &init.name);
|
||||
|
||||
ret = devm_clk_hw_register(dev, &rk808_clkout->clkout2_hw);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return devm_of_clk_add_hw_provider(&pdev->dev, of_clk_rk808_get,
|
||||
rk808_clkout);
|
||||
}
|
||||
|
||||
static struct platform_driver rk808_clkout_driver = {
|
||||
.probe = rk808_clkout_probe,
|
||||
.driver = {
|
||||
.name = "rk808-clkout",
|
||||
},
|
||||
};
|
||||
|
||||
module_platform_driver(rk808_clkout_driver);
|
||||
|
||||
MODULE_DESCRIPTION("Clkout driver for the rk808 series PMICs");
|
||||
MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
|
||||
MODULE_LICENSE("GPL");
|
||||
MODULE_ALIAS("platform:rk808-clkout");
|
@@ -55,12 +55,9 @@ stdenv.mkDerivation {
|
||||
# certain mainline drivers (rk8xx-i2c) can't be compiled as module without also compiling
|
||||
# their runtime dependencies (rk8xx-core), so i end up disabling the whole tree in Kconfig.
|
||||
passthru.moduleNames = [
|
||||
"clk-rk808" #< unchanged from mainline
|
||||
"rk808-regulator" #< unchanged from mainline
|
||||
"rk818_battery" #< new module
|
||||
"rk818_charger" #< new module
|
||||
"rk8xx-core" #< mainline, patched
|
||||
"rk8xx-i2c" #< mainline, patched
|
||||
"rk8xx-spi" #< unchanged from mainline
|
||||
];
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,124 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0
|
||||
/*
|
||||
* Rockchip RK806 Core (SPI) driver
|
||||
*
|
||||
* Copyright (c) 2021 Rockchip Electronics Co., Ltd.
|
||||
* Copyright (c) 2023 Collabora Ltd.
|
||||
*
|
||||
* Author: Xu Shengfei <xsf@rock-chips.com>
|
||||
* Author: Sebastian Reichel <sebastian.reichel@collabora.com>
|
||||
*/
|
||||
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mfd/core.h>
|
||||
#include <linux/mfd/rk808.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
||||
#define RK806_ADDR_SIZE 2
|
||||
#define RK806_CMD_WITH_SIZE(CMD, VALUE_BYTES) \
|
||||
(RK806_CMD_##CMD | RK806_CMD_CRC_DIS | (VALUE_BYTES - 1))
|
||||
|
||||
static const struct regmap_range rk806_volatile_ranges[] = {
|
||||
regmap_reg_range(RK806_POWER_EN0, RK806_POWER_EN5),
|
||||
regmap_reg_range(RK806_DVS_START_CTRL, RK806_INT_MSK1),
|
||||
};
|
||||
|
||||
static const struct regmap_access_table rk806_volatile_table = {
|
||||
.yes_ranges = rk806_volatile_ranges,
|
||||
.n_yes_ranges = ARRAY_SIZE(rk806_volatile_ranges),
|
||||
};
|
||||
|
||||
static const struct regmap_config rk806_regmap_config_spi = {
|
||||
.reg_bits = 16,
|
||||
.val_bits = 8,
|
||||
.max_register = RK806_BUCK_RSERVE_REG5,
|
||||
.cache_type = REGCACHE_MAPLE,
|
||||
.volatile_table = &rk806_volatile_table,
|
||||
};
|
||||
|
||||
static int rk806_spi_bus_write(void *context, const void *vdata, size_t count)
|
||||
{
|
||||
struct device *dev = context;
|
||||
struct spi_device *spi = to_spi_device(dev);
|
||||
struct spi_transfer xfer[2] = { 0 };
|
||||
/* data and thus count includes the register address */
|
||||
size_t val_size = count - RK806_ADDR_SIZE;
|
||||
char cmd;
|
||||
|
||||
if (val_size < 1 || val_size > (RK806_CMD_LEN_MSK + 1))
|
||||
return -EINVAL;
|
||||
|
||||
cmd = RK806_CMD_WITH_SIZE(WRITE, val_size);
|
||||
|
||||
xfer[0].tx_buf = &cmd;
|
||||
xfer[0].len = sizeof(cmd);
|
||||
xfer[1].tx_buf = vdata;
|
||||
xfer[1].len = count;
|
||||
|
||||
return spi_sync_transfer(spi, xfer, ARRAY_SIZE(xfer));
|
||||
}
|
||||
|
||||
static int rk806_spi_bus_read(void *context, const void *vreg, size_t reg_size,
|
||||
void *val, size_t val_size)
|
||||
{
|
||||
struct device *dev = context;
|
||||
struct spi_device *spi = to_spi_device(dev);
|
||||
char txbuf[3] = { 0 };
|
||||
|
||||
if (reg_size != RK806_ADDR_SIZE ||
|
||||
val_size < 1 || val_size > (RK806_CMD_LEN_MSK + 1))
|
||||
return -EINVAL;
|
||||
|
||||
/* TX buffer contains command byte followed by two address bytes */
|
||||
txbuf[0] = RK806_CMD_WITH_SIZE(READ, val_size);
|
||||
memcpy(txbuf+1, vreg, reg_size);
|
||||
|
||||
return spi_write_then_read(spi, txbuf, sizeof(txbuf), val, val_size);
|
||||
}
|
||||
|
||||
static const struct regmap_bus rk806_regmap_bus_spi = {
|
||||
.write = rk806_spi_bus_write,
|
||||
.read = rk806_spi_bus_read,
|
||||
.reg_format_endian_default = REGMAP_ENDIAN_LITTLE,
|
||||
};
|
||||
|
||||
static int rk8xx_spi_probe(struct spi_device *spi)
|
||||
{
|
||||
struct regmap *regmap;
|
||||
|
||||
regmap = devm_regmap_init(&spi->dev, &rk806_regmap_bus_spi,
|
||||
&spi->dev, &rk806_regmap_config_spi);
|
||||
if (IS_ERR(regmap))
|
||||
return dev_err_probe(&spi->dev, PTR_ERR(regmap),
|
||||
"Failed to init regmap\n");
|
||||
|
||||
return rk8xx_probe(&spi->dev, RK806_ID, spi->irq, regmap);
|
||||
}
|
||||
|
||||
static const struct of_device_id rk8xx_spi_of_match[] = {
|
||||
{ .compatible = "rockchip,rk806", },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(of, rk8xx_spi_of_match);
|
||||
|
||||
static const struct spi_device_id rk8xx_spi_id_table[] = {
|
||||
{ "rk806", 0 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(spi, rk8xx_spi_id_table);
|
||||
|
||||
static struct spi_driver rk8xx_spi_driver = {
|
||||
.driver = {
|
||||
.name = "rk8xx-spi",
|
||||
.of_match_table = rk8xx_spi_of_match,
|
||||
},
|
||||
.probe = rk8xx_spi_probe,
|
||||
.id_table = rk8xx_spi_id_table,
|
||||
};
|
||||
module_spi_driver(rk8xx_spi_driver);
|
||||
|
||||
MODULE_AUTHOR("Xu Shengfei <xsf@rock-chips.com>");
|
||||
MODULE_DESCRIPTION("RK8xx SPI PMIC driver");
|
||||
MODULE_LICENSE("GPL");
|
Reference in New Issue
Block a user