Skip to content

Commit fb5fee1

Browse files
committed
Merge tag 'samsung-drivers-7.1' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux into soc/drivers
Samsung SoC drivers for v7.1 Few cleanups in ACPM firmware drivers, used on Google GS101 and newer Samsung Exynos SoCs. Notable change is removing 'const' in 'struct acpm_handle' pointers, because even though the code does not modify pointed data, it immediately drops the const via cast. Also code is not logically readable when a reference getters/putters (e.g. acpm_handle_put()) take a pointer to const, because the meaning of "get" and "put" implies changing the memory, even if that changeable field is outside of pointed data. * tag 'samsung-drivers-7.1' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux: firmware: exynos-acpm: Drop fake 'const' on handle pointer dt-bindings: firmware: google,gs101-acpm-ipc: add S2MPG11 secondary PMIC firmware: exynos-acpm: Count acpm_xfer buffers with __counted_by_ptr firmware: exynos-acpm: Count number of commands in acpm_xfer firmware: exynos-acpm: Use unsigned int for acpm_pmic_linux_errmap index Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents c9da264 + a2be37e commit fb5fee1

10 files changed

Lines changed: 120 additions & 77 deletions

File tree

Documentation/devicetree/bindings/firmware/google,gs101-acpm-ipc.yaml

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ properties:
3737
maxItems: 1
3838

3939
pmic:
40+
deprecated: true
4041
description: Child node describing the main PMIC.
4142
type: object
4243
additionalProperties: true
@@ -45,6 +46,24 @@ properties:
4546
compatible:
4647
const: samsung,s2mpg10-pmic
4748

49+
pmic-1:
50+
description: Child node describing the main PMIC.
51+
type: object
52+
additionalProperties: true
53+
54+
properties:
55+
compatible:
56+
const: samsung,s2mpg10-pmic
57+
58+
pmic-2:
59+
description: Child node describing the sub PMIC.
60+
type: object
61+
additionalProperties: true
62+
63+
properties:
64+
compatible:
65+
const: samsung,s2mpg11-pmic
66+
4867
shmem:
4968
description:
5069
List of phandle pointing to the shared memory (SHM) area. The memory
@@ -62,18 +81,22 @@ additionalProperties: false
6281

6382
examples:
6483
- |
84+
#include <dt-bindings/gpio/gpio.h>
6585
#include <dt-bindings/interrupt-controller/irq.h>
86+
#include <dt-bindings/regulator/samsung,s2mpg10-regulator.h>
6687
6788
power-management {
6889
compatible = "google,gs101-acpm-ipc";
6990
#clock-cells = <1>;
7091
mboxes = <&ap2apm_mailbox>;
7192
shmem = <&apm_sram>;
7293
73-
pmic {
94+
pmic-1 {
7495
compatible = "samsung,s2mpg10-pmic";
7596
interrupts-extended = <&gpa0 6 IRQ_TYPE_LEVEL_LOW>;
7697
98+
vinl3m-supply = <&buck8m>;
99+
77100
regulators {
78101
ldo1m {
79102
regulator-name = "vdd_ldo1";
@@ -82,7 +105,13 @@ examples:
82105
regulator-always-on;
83106
};
84107
85-
// ...
108+
ldo20m {
109+
regulator-name = "vdd_dmics";
110+
regulator-min-microvolt = <700000>;
111+
regulator-max-microvolt = <1300000>;
112+
regulator-always-on;
113+
samsung,ext-control = <S2MPG10_EXTCTRL_LDO20M_EN2>;
114+
};
86115
87116
buck8m {
88117
regulator-name = "vdd_mif";
@@ -93,4 +122,21 @@ examples:
93122
};
94123
};
95124
};
125+
126+
pmic-2 {
127+
compatible = "samsung,s2mpg11-pmic";
128+
interrupts-extended = <&gpa0 7 IRQ_TYPE_LEVEL_LOW>;
129+
130+
vinl1s-supply = <&buck8m>;
131+
vinl2s-supply = <&buck6s>;
132+
133+
regulators {
134+
buckd {
135+
regulator-name = "vcc_ufs";
136+
regulator-ramp-delay = <6250>;
137+
enable-gpios = <&gpp0 1 GPIO_ACTIVE_HIGH>;
138+
samsung,ext-control = <S2MPG11_EXTCTRL_UFS_EN>;
139+
};
140+
};
141+
};
96142
};

drivers/clk/samsung/clk-acpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ struct acpm_clk {
2020
u32 id;
2121
struct clk_hw hw;
2222
unsigned int mbox_chan_id;
23-
const struct acpm_handle *handle;
23+
struct acpm_handle *handle;
2424
};
2525

2626
struct acpm_clk_variant {
@@ -113,7 +113,7 @@ static int acpm_clk_register(struct device *dev, struct acpm_clk *aclk,
113113

114114
static int acpm_clk_probe(struct platform_device *pdev)
115115
{
116-
const struct acpm_handle *acpm_handle;
116+
struct acpm_handle *acpm_handle;
117117
struct clk_hw_onecell_data *clk_data;
118118
struct clk_hw **hws;
119119
struct device *dev = &pdev->dev;

drivers/firmware/samsung/exynos-acpm-dvfs.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright 2025 Linaro Ltd.
66
*/
77

8+
#include <linux/array_size.h>
89
#include <linux/bitfield.h>
910
#include <linux/firmware/samsung/exynos-acpm-protocol.h>
1011
#include <linux/ktime.h>
@@ -24,12 +25,12 @@ static void acpm_dvfs_set_xfer(struct acpm_xfer *xfer, u32 *cmd, size_t cmdlen,
2425
unsigned int acpm_chan_id, bool response)
2526
{
2627
xfer->acpm_chan_id = acpm_chan_id;
28+
xfer->txcnt = cmdlen;
2729
xfer->txd = cmd;
28-
xfer->txlen = cmdlen;
2930

3031
if (response) {
32+
xfer->rxcnt = cmdlen;
3133
xfer->rxd = cmd;
32-
xfer->rxlen = cmdlen;
3334
}
3435
}
3536

@@ -42,15 +43,15 @@ static void acpm_dvfs_init_set_rate_cmd(u32 cmd[4], unsigned int clk_id,
4243
cmd[3] = ktime_to_ms(ktime_get());
4344
}
4445

45-
int acpm_dvfs_set_rate(const struct acpm_handle *handle,
46+
int acpm_dvfs_set_rate(struct acpm_handle *handle,
4647
unsigned int acpm_chan_id, unsigned int clk_id,
4748
unsigned long rate)
4849
{
4950
struct acpm_xfer xfer = {0};
5051
u32 cmd[4];
5152

5253
acpm_dvfs_init_set_rate_cmd(cmd, clk_id, rate);
53-
acpm_dvfs_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id, false);
54+
acpm_dvfs_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id, false);
5455

5556
return acpm_do_xfer(handle, &xfer);
5657
}
@@ -62,15 +63,15 @@ static void acpm_dvfs_init_get_rate_cmd(u32 cmd[4], unsigned int clk_id)
6263
cmd[3] = ktime_to_ms(ktime_get());
6364
}
6465

65-
unsigned long acpm_dvfs_get_rate(const struct acpm_handle *handle,
66+
unsigned long acpm_dvfs_get_rate(struct acpm_handle *handle,
6667
unsigned int acpm_chan_id, unsigned int clk_id)
6768
{
6869
struct acpm_xfer xfer;
6970
unsigned int cmd[4] = {0};
7071
int ret;
7172

7273
acpm_dvfs_init_get_rate_cmd(cmd, clk_id);
73-
acpm_dvfs_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id, true);
74+
acpm_dvfs_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id, true);
7475

7576
ret = acpm_do_xfer(handle, &xfer);
7677
if (ret)

drivers/firmware/samsung/exynos-acpm-dvfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111

1212
struct acpm_handle;
1313

14-
int acpm_dvfs_set_rate(const struct acpm_handle *handle,
14+
int acpm_dvfs_set_rate(struct acpm_handle *handle,
1515
unsigned int acpm_chan_id, unsigned int id,
1616
unsigned long rate);
17-
unsigned long acpm_dvfs_get_rate(const struct acpm_handle *handle,
17+
unsigned long acpm_dvfs_get_rate(struct acpm_handle *handle,
1818
unsigned int acpm_chan_id,
1919
unsigned int clk_id);
2020

drivers/firmware/samsung/exynos-acpm-pmic.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static const int acpm_pmic_linux_errmap[] = {
4141
[2] = -EACCES, /* Write register can't be accessed or issues to access it. */
4242
};
4343

44-
static int acpm_pmic_to_linux_err(int err)
44+
static int acpm_pmic_to_linux_err(unsigned int err)
4545
{
4646
if (err >= 0 && err < ARRAY_SIZE(acpm_pmic_linux_errmap))
4747
return acpm_pmic_linux_errmap[err];
@@ -63,8 +63,8 @@ static void acpm_pmic_set_xfer(struct acpm_xfer *xfer, u32 *cmd, size_t cmdlen,
6363
{
6464
xfer->txd = cmd;
6565
xfer->rxd = cmd;
66-
xfer->txlen = cmdlen;
67-
xfer->rxlen = cmdlen;
66+
xfer->txcnt = cmdlen;
67+
xfer->rxcnt = cmdlen;
6868
xfer->acpm_chan_id = acpm_chan_id;
6969
}
7070

@@ -77,7 +77,7 @@ static void acpm_pmic_init_read_cmd(u32 cmd[4], u8 type, u8 reg, u8 chan)
7777
cmd[3] = ktime_to_ms(ktime_get());
7878
}
7979

80-
int acpm_pmic_read_reg(const struct acpm_handle *handle,
80+
int acpm_pmic_read_reg(struct acpm_handle *handle,
8181
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
8282
u8 *buf)
8383
{
@@ -86,7 +86,7 @@ int acpm_pmic_read_reg(const struct acpm_handle *handle,
8686
int ret;
8787

8888
acpm_pmic_init_read_cmd(cmd, type, reg, chan);
89-
acpm_pmic_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id);
89+
acpm_pmic_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id);
9090

9191
ret = acpm_do_xfer(handle, &xfer);
9292
if (ret)
@@ -107,7 +107,7 @@ static void acpm_pmic_init_bulk_read_cmd(u32 cmd[4], u8 type, u8 reg, u8 chan,
107107
FIELD_PREP(ACPM_PMIC_VALUE, count);
108108
}
109109

110-
int acpm_pmic_bulk_read(const struct acpm_handle *handle,
110+
int acpm_pmic_bulk_read(struct acpm_handle *handle,
111111
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
112112
u8 count, u8 *buf)
113113
{
@@ -119,7 +119,7 @@ int acpm_pmic_bulk_read(const struct acpm_handle *handle,
119119
return -EINVAL;
120120

121121
acpm_pmic_init_bulk_read_cmd(cmd, type, reg, chan, count);
122-
acpm_pmic_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id);
122+
acpm_pmic_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id);
123123

124124
ret = acpm_do_xfer(handle, &xfer);
125125
if (ret)
@@ -150,7 +150,7 @@ static void acpm_pmic_init_write_cmd(u32 cmd[4], u8 type, u8 reg, u8 chan,
150150
cmd[3] = ktime_to_ms(ktime_get());
151151
}
152152

153-
int acpm_pmic_write_reg(const struct acpm_handle *handle,
153+
int acpm_pmic_write_reg(struct acpm_handle *handle,
154154
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
155155
u8 value)
156156
{
@@ -159,7 +159,7 @@ int acpm_pmic_write_reg(const struct acpm_handle *handle,
159159
int ret;
160160

161161
acpm_pmic_init_write_cmd(cmd, type, reg, chan, value);
162-
acpm_pmic_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id);
162+
acpm_pmic_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id);
163163

164164
ret = acpm_do_xfer(handle, &xfer);
165165
if (ret)
@@ -187,7 +187,7 @@ static void acpm_pmic_init_bulk_write_cmd(u32 cmd[4], u8 type, u8 reg, u8 chan,
187187
}
188188
}
189189

190-
int acpm_pmic_bulk_write(const struct acpm_handle *handle,
190+
int acpm_pmic_bulk_write(struct acpm_handle *handle,
191191
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
192192
u8 count, const u8 *buf)
193193
{
@@ -199,7 +199,7 @@ int acpm_pmic_bulk_write(const struct acpm_handle *handle,
199199
return -EINVAL;
200200

201201
acpm_pmic_init_bulk_write_cmd(cmd, type, reg, chan, count, buf);
202-
acpm_pmic_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id);
202+
acpm_pmic_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id);
203203

204204
ret = acpm_do_xfer(handle, &xfer);
205205
if (ret)
@@ -220,7 +220,7 @@ static void acpm_pmic_init_update_cmd(u32 cmd[4], u8 type, u8 reg, u8 chan,
220220
cmd[3] = ktime_to_ms(ktime_get());
221221
}
222222

223-
int acpm_pmic_update_reg(const struct acpm_handle *handle,
223+
int acpm_pmic_update_reg(struct acpm_handle *handle,
224224
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
225225
u8 value, u8 mask)
226226
{
@@ -229,7 +229,7 @@ int acpm_pmic_update_reg(const struct acpm_handle *handle,
229229
int ret;
230230

231231
acpm_pmic_init_update_cmd(cmd, type, reg, chan, value, mask);
232-
acpm_pmic_set_xfer(&xfer, cmd, sizeof(cmd), acpm_chan_id);
232+
acpm_pmic_set_xfer(&xfer, cmd, ARRAY_SIZE(cmd), acpm_chan_id);
233233

234234
ret = acpm_do_xfer(handle, &xfer);
235235
if (ret)

drivers/firmware/samsung/exynos-acpm-pmic.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@
1111

1212
struct acpm_handle;
1313

14-
int acpm_pmic_read_reg(const struct acpm_handle *handle,
14+
int acpm_pmic_read_reg(struct acpm_handle *handle,
1515
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
1616
u8 *buf);
17-
int acpm_pmic_bulk_read(const struct acpm_handle *handle,
17+
int acpm_pmic_bulk_read(struct acpm_handle *handle,
1818
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
1919
u8 count, u8 *buf);
20-
int acpm_pmic_write_reg(const struct acpm_handle *handle,
20+
int acpm_pmic_write_reg(struct acpm_handle *handle,
2121
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
2222
u8 value);
23-
int acpm_pmic_bulk_write(const struct acpm_handle *handle,
23+
int acpm_pmic_bulk_write(struct acpm_handle *handle,
2424
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
2525
u8 count, const u8 *buf);
26-
int acpm_pmic_update_reg(const struct acpm_handle *handle,
26+
int acpm_pmic_update_reg(struct acpm_handle *handle,
2727
unsigned int acpm_chan_id, u8 type, u8 reg, u8 chan,
2828
u8 value, u8 mask);
2929
#endif /* __EXYNOS_ACPM_PMIC_H__ */

0 commit comments

Comments
 (0)