Commit Graph

1056411 Commits

Author SHA1 Message Date
Joseph Chen
cbc7fae477 ARM: dts: rk3036: enable rk3036 PSCI
Change-Id: I4c5472587583fb176d88e802d2e7fe20daf9ea48
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2021-06-24 15:13:21 +08:00
Simon Xue
ac413a148b dt-bindings: adc: add description for rk1808 saradc
Change-Id: I047410349c527495f5b414d98054e535fc168524
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 18:25:12 +08:00
Liao Huaping
7be803f0d5 init: support init ramfs async
If enable ramfs function, init ramfs async,
can reduce kernel init time.

Change-Id: I95d8ca6d8b9c4e9c738c635c5ee56391cbbe7c16
Signed-off-by: Liao Huaping <huaping.liao@rock-chips.com>
Signed-off-by: Tao Huang <huangtao@rock-chips.com>
2021-06-22 17:27:37 +08:00
Simon Xue
c3a852d019 mm/page_alloc.c: Zero all page struct in advance in memmap_init_zone when CONFIG_ROCKCHIP_THUNDER_BOOT=y
In memmap_init_zone, it check all pages valid or deferred by single page,
then zero and init the corresponding page struct. It is safe to zero all
page struct in advance at once no matter what the state of every page is.
This can save time when booting kernel.

Change-Id: Ieb5864231fbc751e9438be488a77ce442b91ce7b
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:39:02 +08:00
Simon Xue
d762833e82 arm64: dts: rockchip: miss RK3328 WDT clock
Change-Id: I4df6373a3323ebf0fed74dddabc387164cd0aa5c
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:29:40 +08:00
Simon Xue
0973411cbd phy: rockchip-pcie: enable each lane when phy_power_on
Change-Id: I9c56ee76f0c1a9c47878113d1d034760af97cc12
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:23:50 +08:00
Simon Xue
260bbeed89 iio: adc: rockchip_saradc: trigger saradc test via sys for test
Take RK3568 as an example:

start sampling:
echo "chn number" > /sys/devices/platform/fe720000.saradc/saradc_test_chn

stop sampling:
echo 8 > /sys/devices/platform/fe720000.saradc/saradc_test_chn

Change-Id: I320bee7a9a9f293dd83defdede4cd1e5974ec527
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:22:14 +08:00
Simon Xue
a1f97ed189 iio: adc: rockchip_saradc: add support for RK3568
Change-Id: I9d83351b1117eba67277cdd0a32e5d0c59ad1c7f
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:21:53 +08:00
Simon Xue
ee886e22c6 iommu: don't break detach if iommu shared by more than one master
Change-Id: I4fade6e770e124dcaca41d122965e8696f268556
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:21:01 +08:00
Simon Xue
a18904023b iommu: rockchip: update to support module
Change-Id: I4603bf635c362b07a9a1dcab3283b1ed669b581b
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:20:35 +08:00
Simon Xue
6a451a28f7 dt-bindings: iommu: add disable iommu reset and skip iommu read for rockchip iommu
Change-Id: I3f31f5745078717dfecba649ae6aca573eb7f30b
Signed-off-by: Simon Xue <xxm@rock-chips.com>
2021-06-22 16:16:30 +08:00
William Wu
cd8274c6b5 usb: uas: ignore UAS for Seagate Expansion Portable Drive
The Seagate Expansion Portable Drive HDD (idVendor=0bc2, idProduct=2321) is reported to fail to work on rockchip platforms
with the following error message when do read/write operation by dd command:

xhci-hcd xhci-hcd.11.auto: Ring expansion failed

According to tkaiser's suggestion[1], we can try to increase the kernel's
coherent-pool memory size to fix this issue. The kernel coherent-pool memory
size was limited at 256KB by default. When set the DEFAULT_DMA_COHERENT_POOL_SIZE
to 1MB, the error "Ring expansion failed" can be fixed, but it still not
work with the other error message:

xhci-hcd xhci-hcd.12.auto: ERROR Unknown event condition 34 for slot 1 ep 3 , HC probably busted
sd 0:0:0:0: [sda] tag#16 uas_eh_abort_handler 0 uas-tag 17 inflight: CMD OUT
...
scsi host0: uas_eh_bus_reset_handler start
xhci-hcd xhci-hcd.12.auto: ERROR Transfer event for disabled endpoint slot 1 ep 6 or incorrect stream ring

Falling back to USB mass storage can solve this problem, so ignore UAS
function of this HDD.

[1] https://forum.armbian.com/topic/4811-uas-mainline-kernel-coherent-pool-memory-size/

Change-Id: I0d817cc3aaea548c2060b323c3077c6cbbd3bb6e
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 16:06:07 +08:00
William Wu
3c5c1b3dd0 usb: storage: add Genesys Logic 05e3:0749 to unusual_devs.h
When test more than three Genesys Logic usb3 storages
(VID : PID = 0x05e3 : 0x0749) on rockchip platforms with
usb3 host port (e.g. rk3328/rk3399) at the same time,

test commands like this:
for dev in `ls /dev/sd?1 | sed -e 's,1$,,'`; do
	echo dd if=$dev of=/dev/null
	dd if=$dev of=/dev/null &
	sleep 1
done

The test fail with the following error log:
xhci-hcd xhci-hcd.9.auto: xHCI host not responding to stop endpoint command.
xhci-hcd xhci-hcd.9.auto: Assuming host is dying, halting host.
xhci-hcd xhci-hcd.9.auto: Host not halted after 16000 microseconds.
xhci-hcd xhci-hcd.9.auto: Non-responsive xHCI host is not halting.
xhci-hcd xhci-hcd.9.auto: Completing active URBs anyway.
xhci-hcd xhci-hcd.9.auto: HC died; cleaning up

This patch sets the max_sectors to 128 (64K) to workaround
this issue, and it doesn't affect the transmission rate.

Change-Id: Idd9cc81659d27c12b142f6c4375558c2262e800d
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 16:05:48 +08:00
William Wu
9e3315b96a usb: uas: Add JMicron JMS583 and CHIPFANCIER to unusual device
These two devices give the following error on detection.
Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
xhci-hcd xhci-hcd.5.auto: ERROR Transfer event for disabled endpoint
or incorrect stream ring

The same error is not seen when it is added to unusual_device
list with US_FL_NO_REPORT_OPCODES and US_FL_BROKEN_FUA passed.

Change-Id: Ia1035ea597c65ad7112f68f5cbdd792875ee2995
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 16:05:36 +08:00
William Wu
9f6e60eee6 uvcvideo: add quirk for dev parent with broken auto suspend
If the parent of uvc device has a quirk for broken
auto-suspend function (e.g. rk3328 usb 3.0 root hub),
we also need to disable auto-suspend for the uvc device.

Change-Id: Ida8d05a411f49f39e13cad3ec837a56598b4a630
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 16:05:20 +08:00
William Wu
f078cc7762 usb: quirks: add device quirk for Sonix FaceBlack device
We found that some Sonix usb cameras(e.g. idVendor=0c45,
idProduct=64ab or idProduct=64ac) can't support auto-suspend
well on rockchip platforms(e.g. rk3399).With auto-suspend,
these usb cameras MJPEG will display abnormally on all usb
controllers(DWC2/DWC3/EHCI). So we need to disable auto-
suspend for these special usb cameras.

Change-Id: I08c87cf5c9fa5ebe076b5dd3e873b74c5ec2cb83
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 15:42:18 +08:00
William Wu
3a4301edee usb: quirks: add device quirk for HD Camera PID 0x9320
The commit 62b2a34a21 ("uvcvideo: add quirk for devices
with broken auto suspend") introduced quirk to workaround
an issue with some HD Cameras.

There is one more model that has the same issue - idProduct
=0x9320, so applying the same quirk as well.

Change-Id: I24e3fc1746a9d21d529bc91f52fd5822e998bd93
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 15:33:10 +08:00
Wu Liang feng
f21eb9cd0a uvcvideo: add quirk for devices with broken auto suspend
We found that some usb cameras(e.g. Manufacturer: HD Camera
Manufacturer, idVendor=05a3, idProduct=9230) can't support
auto-suspend well on rockchip platforms. With auto-suspend,
these usb cameras MJPEG will display abnormally on all usb
controllers(DWC2/DWC3/EHCI). So we need to disable auto
suspend for these special usb cameras.

Change-Id: Ibf50ed77edff0012a112dc42f09e022055908829
Signed-off-by: Wu Liang feng <wulf@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 15:33:10 +08:00
William Wu
ee79d6800b usb: core: hub: add quirk for hub with broken autosuspend function
Some USB host controller seems to have problems with
autosuspend. For example, Rockchip rk3328 SoC USB 3.0
wouldn't handle remote wakeup correctly with external
hub after entered autosuspend, caused to resume SS
port fail.

This patch introduces a new quirk flag for hub that
should remain disabled for autosuspend.

Change-Id: I6d14222b2c5025583fea811a6afd6abd22f41cb9
Signed-off-by: William Wu <wulf@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 15:33:10 +08:00
William Wu
b5f3551f96 tools: ffs-aio-example: add superspeed descriptors
This patch adds superspeed descriptors in device
applications to support USB 3.0 ffs gadget.

Change-Id: I5a364c935b1d30e2e929791ff16a34cf0d1c87e1
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-22 15:19:23 +08:00
Jon Lin
8c3cf7cb12 spi: rockchip: Stop spi slave dma receiver when cs inactive
The spi which's version is higher than ver 2 will automatically
enable this feature.

If the length of master transmission is uncertain, the RK spi slave
is better to automatically stop after cs inactive instead of waiting
for xfer_completion forever.

Change-Id: If99e51d35391b824f48e31a3e4508db036593c8a
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-06-21 18:13:20 +08:00
Jon Lin
e813e95f5f spi: rockchip: Support SPI_CS_HIGH
1.Add standard spi-cs-high support
2.Refer to spi-controller.yaml for details

Change-Id: I899bce8d9418ee99c784726bb56534aaed27c00b
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-06-21 18:12:27 +08:00
Jon Lin
73d5e1d445 spi: rockchip: Support cs-gpio
1.Add standard cs-gpio support
2.Refer to spi-controller.yaml for details

Change-Id: I8f839189038afd77d534d767d938c845aa54fedb
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-06-21 16:48:45 +08:00
Jon Lin
c434048c2e FROMLIST: spi: rockchip: Wait for STB status in slave mode tx_xfer
After ROCKCHIP_SPI_VER2_TYPE2, SR->STB is a more accurate judgment
bit for spi slave transmission.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210615033213.14241-5-jon.lin@rock-chips.com/
Change-Id: I39fe2b9e5a84304e7d0320842399a02a4b0743a0
2021-06-21 09:43:39 +08:00
Jon Lin
1458738a72 FROMLIST: spi: rockchip: Set rx_fifo interrupt waterline base on transfer item
The error here is to calculate the width as 8 bits. In fact, 16 bits
should be considered.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210615033213.14241-4-jon.lin@rock-chips.com/
Change-Id: Ia141ce99b14f8728302535d0748af66d597a2fdc
2021-06-21 09:40:57 +08:00
Jon Lin
0c936c1801 FROMLIST: dt-bindings: spi: spi-rockchip: add description for rv1126
The description below will be used for rv1126.dtsi or compatible one in
the future

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Acked-by: Rob Herring <robh@kernel.org>
Link: https://patchwork.kernel.org/project/linux-arm-kernel/patch/20210615033213.14241-2-jon.lin@rock-chips.com/
Change-Id: Ibf4452a6fb03643cc8f3ded0677db863e9a986ab
2021-06-18 18:04:36 +08:00
Jon Lin
0b060a7b8b spi: rockchip: add compatible string for rv1126
Add compatible string for rv1126 for potential applications.

Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
Change-Id: I2ad2de0c715b064870b35214f25e9705412fd62f
2021-06-18 17:56:19 +08:00
Jon Lin
40145ca4e0 spi: rockchip: set higher io driver when sclk higher than 24MHz
Fixes: f27d8c9975 ("spi: rockchip: get pinctrl for lookup pinctrl state")
Fixes: 87dbea63d5 ("spi: rockchip: set higher io driver when sclk higher than 24MHz")
Change-Id: I963c92eab7f7bff0b32e2ac262aa79f0667f39ee
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-06-18 17:53:25 +08:00
Huibin Hong
4239fdd85b spi: spidev: Add rockchip spidev compatible string
Change-Id: I0ba866f7f17be3063bbe405ac9d62f83e54443a4
Signed-off-by: Huibin Hong <huibin.hong@rock-chips.com>
Signed-off-by: Yifeng Zhao <zyf@rock-chips.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
2021-06-18 17:49:11 +08:00
Bin Yang
54c3040ede phy: rockchip: inno-usb2: fix iddig issues for rk3568
RK3568 u2phy used shared interrupt and do not used id irq.

Change-Id: I341cc0edb0f74996f159c095545465673cc2a990
Signed-off-by: Bin Yang <yangbin@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
William Wu
40d5086cb9 phy: rockchip: inno-usb2: increase hs eye height for otg port
Test on RK3568S EVB1, the otg device data eye test fail with
far end template when use 1.2 meter long cable. So tuning
the hs eye height from 400mv(default) to 437.5mv. And we
test on RK3568 EVB1, it can also benefit from this patch.

Change-Id: Ie2342aba5546990838fdd6faf27a007a8843fd0d
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
William Wu
96560cb2ee phy: rockchip: naneng-combphy: adjust PLL parameters for USB
When do USB 3.0 Receiver Jitter Tolerance Test, it fails at
Sj Frequency 2.0/4.9/10.0 [MHz]. This patch adjusts the PLL
parameters for USB to pass the Receiver Jitter Tolerance Test,
and it's helpful to improve the USB 3.0 signal compatibility.

Change-Id: I58eb687a4677fe22cf5bc324578b033526310859
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
William Wu
559e760d78 phy: rockchip-typec: set usb3 to usb2 only for dp 4 lanes
If the Type-C PHY works as DP 4 lanes, the Tx/Rx lanes
of Type-C USB 3.0 PHY is used for DP lanes, so it needs
to force the USB 3.0 to USB 2.0 only, and make sure USB
3.0 xHCI controller doesn't support USB 3.0 port.

With this patch, an ASUS Type-C to HDMI dongle which
supports DP 4 lanes and USB 2.0 simultaneously can
suspend/resume successfully.

Change-Id: I77049702c768bd56d638d11c29aae07eeb608282
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
Douglas Anderson
96cb061468 FROMLIST: phy: rockchip-typec: Try to turn the PHY on several times
Bind / unbind stress testing of the USB controller on rk3399 found
that we'd often end up with lots of failures that looked like this:

  phy phy-ff800000.phy.9: phy poweron failed --> -110
  dwc3 fe900000.dwc3: failed to initialize core
  dwc3: probe of fe900000.dwc3 failed with error -110

Those errors were sometimes seen at bootup too, in which case USB
peripherals wouldn't work until unplugged and re-plugged in.

I spent some time trying to figure out why the PHY was failing to
power on but I wasn't able to.  Possibly this has to do with the fact
that the PHY docs say that the USB controller "needs to be held in
reset to hold pipe power state in P2 before initializing the Type C
PHY" but that doesn't appear to be easy to do with the dwc3 driver
today.  Messing around with the ordering of the reset vs. the PHY
initialization in the dwc3 driver didn't seem to fix things.

I did, however, find that if I simply retry the power on it seems to
have a good chance of working.  So let's add some retries.  I ran a
pretty tight bind/unbind loop overnight.  When I did so, I found that
I need to retry between 1% and 2% of the time.  Overnight I found only
a small handful of times where I needed 2 retries.  I never found a
case where I needed 3 retries.

I'm completely aware of the fact that this is quite an ugly hack and I
wish I didn't have to resort to it, but I have no other real idea how
to make this hardware reliable.  If Rockchip in the future can come up
with a solution we can always revert this hack.  Until then, let's at
least have something that works.

This patch is tested atop Enric's latest dwc3 patch series ending at:
  https://patchwork.kernel.org/patch/10095527/
...but it could be applied independently of that series without any
bad effects.

For some more details on this bug, you can refer to:
  https://bugs.chromium.org/p/chromium/issues/detail?id=783464

Change-Id: I7909731247739694f56bf89ab3064889f2b34d3c
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
(am from https://patchwork.kernel.org/patch/10105833/)
2021-06-17 09:09:54 +08:00
Wyon Bi
cc74ace23f phy: rockchip-typec: support variable phy config value
the phy config values used to fix in dp firmware, but some boards
need change these values to do training and get the better eye diagram
result. So support that in phy driver.

Change-Id: I195727b2a81130606e66ffc4471df74e5782a7fa
Signed-off-by: Chris Zhong <zyw@rock-chips.com>
Signed-off-by: Lin Huang <hl@rock-chips.com>
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
William Wu
d9e99cda26 phy: phy-rockchip-inno-usb3: add Kconfig and Makefile
Change-Id: I0e71b5574f70824ea7ea3c14bda2eaa005a0394b
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-17 09:09:54 +08:00
William Wu
62c5e6af1c usb: gadget: f_uvc: disallow the CPU to enter deeper sleep when streamon
I test on RK3399 IND EVB running Android R system, and
set the USB gadget as UVC function via configfs, both
the USB 2.0 and 3.0 UVC have preview abnormal problems.
If the CPU enter deeper sleep, the USB DMA transfer gets
corrupted, and the UVC ISOC transmission lost data.

This patch puts in a "pm_qos_latency" requirement which
will keep the CPU out of the deeper sleep states when
UVC stream on. And allow the CPU to enter deeper sleep
state after UVC stream off.

Change-Id: I808290f124c6a32da3888819348093a205bfad61
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 19:16:52 +08:00
William Wu
7bb8939e5c usb: gadget: f_uvc: add suspend and resume function
This patch adds uvc_function_suspend and uvc_function_resume
for uvc function. With this patch, if usb bus enter suspend
or resume state, the usb controller driver will call the
uvc_function_suspend or uvc_function_resume to send event
to uvc app.

Change-Id: I9c584aae25298747c5a287243cb3efd71c8adfe6
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 19:16:52 +08:00
William Wu
376cc3f4d2 usb: gadget: f_uvc: trace uvc control request
This patch add new uvc trace for setup request processing.

1. enable trace
   echo 4 > /sys/module/usb_f_uvc/parameters/trace

2. dump trace
   dmesg

Test on RV1109 EVB with UVC function when streaming on:

[  426.441316] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.450280] uvcvideo: uvc_send_response: req len 26
[  426.450444] uvcvideo: event_setup_out 0, data len 26
[  426.451545] uvcvideo: setup request 21 01 value 0100 index 0003 001a
[  426.460862] uvcvideo: uvc_send_response: req len 26
[  426.461014] uvcvideo: event_setup_out 1, data len 26
[  426.461173] uvcvideo: setup request a1 81 value 0100 index 0003 001a
[  426.485791] uvcvideo: uvc_send_response: req len 26
[  426.486672] uvcvideo: event_setup_out 0, data len 26
[  426.487145] uvcvideo: setup request a1 83 value 0100 index 0003 001a
[  426.496529] uvcvideo: uvc_send_response: req len 26
[  426.496655] uvcvideo: event_setup_out 0, data len 26
[  426.497485] uvcvideo: setup request a1 82 value 0100 index 0003 001a
[  426.506737] uvcvideo: uvc_send_response: req len 26
[  426.507195] uvcvideo: event_setup_out 0, data len 26

Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: If882728e891d033c249e6c466b40d3e2a28bccb6
2021-06-16 19:16:52 +08:00
William Wu
71a43ff15c usb: gadget: f_uac1: finalize wMaxPacketSize according to bandwidth
According to USB Audio Device 1.0 Spec, Ch4.6.1.1:
The wMaxPacketSize of endpoint is defined as follows:
Maximum packet size of endpoint is capable of sending
or receiving when this configuration is selected. This
is determined by the audio bandwidth constraints of
the endpoint.

In current code, the wMaxPacketSize is limited to 200,
and the bInterval is set to 4 (1ms). That is, the maximum
bandwidth over USB bus is 200 * 1000 = 200000 bytes.

We find an issue about bandwidth limitation when we try to
support UAC1 with 8ch * 16bit * 16KHz on RK3308 platform,
which needs more bandwidth than it can support.

This patch sets the wMaxPacketSize dynamically according
to the parameters of UAC1. It is similar to the same thing
done earlier for f_uac2.

Change-Id: I9af3fd7665a80b5eb0cfb5dc91ebe2c20df1dd46
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
Ren Jianing
be7c4cf14b usb: gadget: u_audio: add uevent for ppm compensation
This patch add uevent to notify the application layer how much ppm
is different between USB clk and AUDIO clk.

The event include two parts USB_STATE and PPM. For example:

  g_audio_work: sent uac uevent USB_STATE=SET_AUDIO_CLK PPM=12
  g_audio_work: sent uac uevent USB_STATE=SET_AUDIO_CLK PPM=-1

Note: The ppm compensation depends on the method implement of
clk drift and compensation in the rockchip_pdm.c driver. So if
you want the ppm compensation to take effect, please make sure
the commit "ASoC: rockchip: pdm: Add support for clk compensation"
is merged.

Change-Id: Id25411397fe376342c773c11f1989ed5854f8ad9
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
Ren Jianing
7e08fbf2c8 usb: gadget: f_fs: fix ep req_match error for composite device
This patch add direction index for eps_revmap, which can avoid matching
to the requests for other functions.

For example, if we config ep1in for uac and ep1out for adb, the requests
for ep1in will be matching to ffs without this patch.

Change-Id: Ic7a52fca35503656bbc306c9f0014dfdea61392b
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:21 +08:00
William Wu
bcf7606d61 usb: gadget: add transfer_type in struct usb_ep for rockchip
The usb gadget core set the chosen endpoint descriptor for
each endpoints in config_ep_by_speed(), however, we want
to get the transfer type of the endpoints earlier on the
rockchip platforms for usb controller initialization
(e.g. do tx fifos resize for rockchip usb dwc3 controller),
so this patch add transfer_type in the struct usb_ep, and
set the transfer_type in the usb_ep_autoconfig_ss().

Change-Id: Ia2added218e180dda7a7ca5da09ee18d63be1ff0
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:22:19 +08:00
Ren Jianing
be3429e9b2 usb: gadget: f_uac: add pktsize calculating at setting playback srate
Without this patch, we only calculate usb request packet_size when
start playback. If PC set sample rate after opening stream, the value
of packet_size will not be updated to uac driver and the gadget will
send error size of pcm data.

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Iaa54ed740c98e5f12bf9cf680b50cf4be931cfbd
2021-06-16 18:21:34 +08:00
William Wu
c55a0ab282 usb: gadget: f_uac: add volume and mute feature unit
This patch adds feature unit descriptor for f_uac1 and f_uac2,
and supports volume control and mute control for capture and
playback.

By default, the volume and mute feature unit descriptors are NOT
add in the UAC descriptor. The user can define whether the UAC1/
UAC2 shall support volume and mute functionality via the attributes
c_feature_unit/p_feature_unit in the UAC function directory.

For example, user can add the volume and mute feature unit descriptors
for UAC1 capture and playback:

echo 1 > /config/usb-gadget/gadget/functions/uac1.name/c_feature_unit
echo 1 > /config/usb-gadget/gadget/functions/uac1.name/p_feature_unit

This patch also adds uevents for volume and mute functionality. The
user can complete the real volume and mute control functionality in
the user space depends on these new uevents (like the uac_app in the
RV1126/RV1109 SDK).

Change-Id: I76d447a19fd69e038851040cd73e6c7d420f467d
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:15:08 +08:00
William Wu
adc23c13ff usb: gadget: f_rndis: handle the packet filter class request
This patch handles the class specific control request
"USB_CDC_SET_ETHERNET_PACKET_FILTER" for rndis. Actually,
the cdc_filter is not rndis specific, so we don't really
set the cdc_filter to the wValue of setup request for
rndis, and just return value 0 for the setup request to
avoid usb controllers stall ep0.

Change-Id: I42f9835a9812b8dfa640562b8555bc5f9b022256
Signed-off-by: William Wu <william.wu@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00
Ren Jianing
ac1ed698c3 usb: gadget: u_audio: add uevent for set_alt and set_srate
This patch add uevent to notify the application layer when it should
playback or capture and setting the accuration sample rate.

The event consists of three parts, namely USB_STATE, STREAM_DIRECTION
and STREAM_STATE. For example:

g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=IN STREAM_STATE=OFF
g_audio_work: sent uac uevent USB_STATE=SET_INTERFACE STREAM_DIRECTION=OUT STREAM_STATE=ON
g_audio_work: sent uac uevent USB_STATE=SET_SAMPLE_RATE STREAM_DIRECTION=OUT SAMPLE_RATE=44100

Signed-off-by: Ren Jianing <jianing.ren@rock-chips.com>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Ia01572d92d0c3ae40b19e772571282b8806da9e5
2021-06-16 18:13:14 +08:00
Ren Jianing
37ed8f4607 FROMLIST: usb: gadget: f_uac*: Support multiple sampling rates
Implement support for multiple sampling rates in the USB Audio gadgets.
A list of sampling rates can be specified via configfs. All enabled
sampling rates are sent to the USB host on request. When the host
selects a sampling rate the internal active rate is updated. The
currently configured rates are exposed through amixer controls. Also on
pcm open from userspace the requested rated is checked against the
currently configured rate of the host.

Link: https://lore.kernel.org/patchwork/patch/805286/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: I43dc28462062c9aa179c2b9c8e7e50c307137874
2021-06-16 18:13:14 +08:00
Ren Jianing
70267887d6 FROMLIST: usb: gadget: f_uac*: Reduce code duplication
This replaces the dedicated headers for uac1 and uac2 functions with a
shared header for both of them. Apart from unifying the struct names,
further duplicated code for configfs setup is moved out of the function
files into the shared header.

Link: https://lore.kernel.org/patchwork/patch/805285/
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
Change-Id: Ie866bd02f174dc91168fe0bc49b571a77d849a42
2021-06-16 18:13:14 +08:00
Julian Scheel
d390fcf2f7 FROMLIST: usb: gadget: f_uac1: Fix endpoint reading
The endpoint is stored in the lower byte of wIndex, according to USB
Audio 1.0 specification, section 5.2.1.1.

Link: https://lore.kernel.org/patchwork/patch/805284/
Change-Id: I16634151e98cfb0f7107e96463a20b8fa8d7072f
Signed-off-by: Julian Scheel <julian@jusst.de>
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2021-06-16 18:13:14 +08:00