Skip to content

Commit 4a9830c

Browse files
committed
Merge branch 'refs/heads/bits/170-atcphy' into asahi-wip
2 parents 9f04511 + e3ed55c commit 4a9830c

10 files changed

Lines changed: 2737 additions & 18 deletions

File tree

drivers/nvmem/core.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ static int nvmem_cell_info_to_nvmem_cell_entry_nodup(struct nvmem_device *nvmem,
471471
cell->np = info->np;
472472

473473
if (cell->nbits)
474-
cell->bytes = DIV_ROUND_UP(cell->nbits + cell->bit_offset,
475-
BITS_PER_BYTE);
474+
cell->bytes = round_up(DIV_ROUND_UP(cell->nbits + cell->bit_offset,
475+
BITS_PER_BYTE), nvmem->word_size);
476476

477477
if (!IS_ALIGNED(cell->offset, nvmem->stride)) {
478478
dev_err(&nvmem->dev,
@@ -1382,15 +1382,23 @@ EXPORT_SYMBOL_GPL(nvmem_cell_put);
13821382
static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void *buf)
13831383
{
13841384
u8 *p, *b;
1385-
int i, extra, bit_offset = cell->bit_offset;
1385+
int i, padding, extra, bit_offset = cell->bit_offset;
1386+
int bytes = cell->bytes;
13861387

13871388
p = b = buf;
13881389
if (bit_offset) {
1390+
padding = bit_offset/8;
1391+
if (padding) {
1392+
memmove(buf, buf + padding, bytes - padding);
1393+
bit_offset -= BITS_PER_BYTE * padding;
1394+
bytes -= padding;
1395+
}
1396+
13891397
/* First shift */
13901398
*b++ >>= bit_offset;
13911399

13921400
/* setup rest of the bytes if any */
1393-
for (i = 1; i < cell->bytes; i++) {
1401+
for (i = 1; i < bytes; i++) {
13941402
/* Get bits from next byte and shift them towards msb */
13951403
*p |= *b << (BITS_PER_BYTE - bit_offset);
13961404

@@ -1403,7 +1411,7 @@ static void nvmem_shift_read_buffer_in_place(struct nvmem_cell_entry *cell, void
14031411
}
14041412

14051413
/* result fits in less bytes */
1406-
extra = cell->bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
1414+
extra = bytes - DIV_ROUND_UP(cell->nbits, BITS_PER_BYTE);
14071415
while (--extra >= 0)
14081416
*p-- = 0;
14091417

drivers/phy/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ config PHY_CAN_TRANSCEIVER
7373

7474
source "drivers/phy/allwinner/Kconfig"
7575
source "drivers/phy/amlogic/Kconfig"
76+
source "drivers/phy/apple/Kconfig"
7677
source "drivers/phy/broadcom/Kconfig"
7778
source "drivers/phy/cadence/Kconfig"
7879
source "drivers/phy/freescale/Kconfig"

drivers/phy/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ obj-$(CONFIG_PHY_PISTACHIO_USB) += phy-pistachio-usb.o
1212
obj-$(CONFIG_USB_LGM_PHY) += phy-lgm-usb.o
1313
obj-y += allwinner/ \
1414
amlogic/ \
15+
apple/ \
1516
broadcom/ \
1617
cadence/ \
1718
freescale/ \

drivers/phy/apple/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
2+
config PHY_APPLE_ATC
3+
tristate "Apple Type-C PHY"
4+
depends on ARCH_APPLE || COMPILE_TEST
5+
default ARCH_APPLE
6+
select GENERIC_PHY
7+
select TYPEC
8+
help
9+
Enable this to add support for the Apple Type-C PHY, switch
10+
and mux found in Apple SoCs such as the M1.
11+
This driver currently provides support for USB2 and USB3.

drivers/phy/apple/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
2+
CFLAGS_trace.o := -I$(src)
3+
4+
obj-$(CONFIG_PHY_APPLE_ATC) += phy-apple-atc.o
5+
phy-apple-atc-y := atc.o
6+
phy-apple-atc-$(CONFIG_TRACING) += trace.o

0 commit comments

Comments
 (0)