Binbin Zhou
ef7ab3051c
LoongArch: dts: Add SDIO controller support to Loongson-2K0500
...
The Loongson-2K0500 integrates two SDIO controllers for SD storage cards
and SDIO cards, supporting SD storage card boot.
The module is supported now, enable it.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:17 +08:00
Binbin Zhou
9955910d9f
LoongArch: dts: Add eMMC/SDIO controller support to Loongson-2K2000
...
The Loongson-2K2000 integrates one eMMC controller and one SDIO controller.
The module is supported now, enable it.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:17 +08:00
Binbin Zhou
8d8056f388
mmc: loongson2: Unify the function prefixes for loongson2_mmc_pdata
...
The function prefixes for loongson2_mmc_pdata follow two naming
conventions: SoC-based and DMA-based.
First, DMA-based prefixes are the preferred choice, as they clearly
highlight differences, such as prepare_dma; however, for functions
related to SoC, such as reorder_cmd_data, it is agreed to use the
smallest SoC name as the fallback prefix, such as ls2k0500.
No functional change intended.
Suggested-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn >
Link: https://lore.kernel.org/r/20250716064421.3823418-1-zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:17 +08:00
Binbin Zhou
77dca90f0e
mmc: loongson2: Add Loongson-2K2000 SD/SDIO/eMMC controller driver
...
This patch describes the two MMC controllers of the Loongson-2K2000 SoC,
one providing an eMMC interface and the other exporting an SD/SDIO
interface.
Compared to the Loongson-2K1000's MMC controllers, their internals are
similar, except that we use an internally exclusive DMA engine instead of
an externally shared APBDMA engine.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn >
Link: https://lore.kernel.org/r/1df46b976abd36003bd553ad8a039e5c97369df0.1750765495.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:17 +08:00
Binbin Zhou
d12f65a0ef
mmc: loongson2: Add Loongson-2K SD/SDIO controller driver
...
The MMC controllers on the Loongson-2K series CPUs are similar,
except for the interface characteristics and the use of DMA controllers.
This patch describes the MMC controllers on the Loongson-2K0500/2K1000,
with the distinguishing feature being the use of an externally shared
APBDMA engine.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn >
Link: https://lore.kernel.org/r/c0a9f0c0279d8e09165c6e2d694b0c35f7fc7e31.1750765495.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:16 +08:00
Binbin Zhou
6fd17968ae
dt-bindings: mmc: Add Loongson-2K SD/SDIO/eMMC controller binding
...
Add the Loongson-2K SoC's SD/SDIO/eMMC controller binding with DT schema
format using json-schema.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Rob Herring (Arm) <robh@kernel.org >
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn >
Link: https://lore.kernel.org/r/949c55be120a806ea3d74b47fa2cc96ced2905fc.1750765495.git.zhoubinbin@loongson.cn
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-08-19 11:29:16 +08:00
Binbin Zhou
9eac290915
gpio: loongson-64bit: Correct Loongson-7A2000 ACPI GPIO access mode
...
According to the description of the Loongson-7A2000 ACPI GPIO register in
the manual, its access mode should be BIT_CTRL_MODE, otherwise there maybe
some unpredictable behavior.
Cc: stable@vger.kernel.org
Fixes: 44fe79020b91 ("gpio: loongson-64bit: Add more gpio chip support")
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn >
Link: https://lore.kernel.org/r/20250610115926.347845-1-zhoubinbin@loongson.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-06-20 08:44:44 +08:00
Binbin Zhou
8f52efc76e
LoongArch: dts: Add PWM support to Loongson-2K2000
...
The module is supported, enable it.
Reviewed-by: Yanteng Si <si.yanteng@linux.dev >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-06-20 08:44:43 +08:00
Binbin Zhou
ef0233db6c
LoongArch: dts: Add PWM support to Loongson-2K1000
...
The module is supported, enable it.
Also, add the pwm-fan and cooling-maps associated with it.
Reviewed-by: Yanteng Si <si.yanteng@linux.dev >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-06-20 08:44:43 +08:00
Binbin Zhou
36210e6bd5
LoongArch: dts: Add PWM support to Loongson-2K0500
...
The module is supported, enable it.
Reviewed-by: Yanteng Si <si.yanteng@linux.dev >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-06-20 08:44:42 +08:00
Binbin Zhou
45e4bc304e
gpio: loongson-64bit: Add more gpio chip support
...
The Loongson-7A2000 and Loongson-3A6000 share the same gpio chip model.
Just add them through driver_data.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Acked-by: Huacai Chen <chenhuacai@loongson.cn >
Reviewed-by: Linus Walleij <linus.walleij@linaro.org >
Link: https://lore.kernel.org/r/20250303074552.3335186-2-zhoubinbin@loongson.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-05-30 15:52:38 +08:00
Binbin Zhou
4a8477fb33
ASoC: loongson: Fix build warning when !CONFIG_PCI
...
Fixes the below if kernel config disable PCI support:
sound/soc/loongson/loongson_i2s_pci.c:157:1: warning: data definition has no type or storage class
157 | module_pci_driver(loongson_i2s_driver);
| ^~~~~~~~~~~~~~~~~
sound/soc/loongson/loongson_i2s_pci.c:157:1: error: type defaults to 'int' in declaration of 'module_pci_driver' [-Wimplicit-int]
sound/soc/loongson/loongson_i2s_pci.c:157:1: error: parameter names (without types) in function declaration [-Wdeclaration-missing-parameter-type]
sound/soc/loongson/loongson_i2s_pci.c:149:26: warning: 'loongson_i2s_driver' defined but not used [-Wunused-variable]
149 | static struct pci_driver loongson_i2s_driver = {
| ^~~~~~~~~~~~~~~~~~~
Add the appropriate Kconfig dependency.
Fixes: ba4c5fad598c ("ASoC: loongson: Add I2S controller driver as platform device")
Reported-by: kernel test robot <lkp@intel.com >
Closes: https://lore.kernel.org/oe-kbuild-all/202410101647.o1lI37ou-lkp@intel.com/
Closes: https://lore.kernel.org/oe-kbuild-all/202410101439.Tfn5aT6i-lkp@intel.com/
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://patch.msgid.link/20241012095840.965087-1-zhoubinbin@loongson.cn
Signed-off-by: Mark Brown <broonie@kernel.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-05-30 15:52:37 +08:00
Binbin Zhou
e6c3ec9b19
ASoC: loongson: Add I2S controller driver as platform device
...
The Loongson I2S controller exists not only in PCI form (LS7A bridge
chip), but also in platform device form (Loongson-2K1000 SoC).
This patch adds support for platform device I2S controller.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://patch.msgid.link/36c143358c7f48bc2e73c30e1d2009b2f2fc6498.1728459624.git.zhoubinbin@loongson.cn
Signed-off-by: Mark Brown <broonie@kernel.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-05-30 15:52:37 +08:00
Binbin Zhou
fb713d0ffd
i2c: ls2x: Fix frequency division register access
...
According to the chip manual, the I2C register access type of
Loongson-2K2000/LS7A is "B", so we can only access registers in byte
form (readb()/writeb()).
Although Loongson-2K0500/Loongson-2K1000 do not have similar
constraints, register accesses in byte form also behave correctly.
Also, in hardware, the frequency division registers are defined as two
separate registers (high 8-bit and low 8-bit), so we just access them
directly as bytes.
Cc: stable@vger.kernel.org
Fixes: 015e61f0bffd ("i2c: ls2x: Add driver for Loongson-2K/LS7A I2C controller")
Co-developed-by: Hongliang Wang <wanghongliang@loongson.cn >
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Andy Shevchenko <andy@kernel.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-03-04 11:55:17 +08:00
Binbin Zhou
c9fe5e5ab6
pwm: Add Loongson PWM controller support
...
This commit adds a generic PWM framework driver for the PWM controller
found on Loongson family chips.
Co-developed-by: Juxin Gao <gaojuxin@loongson.cn >
Signed-off-by: Juxin Gao <gaojuxin@loongson.cn >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Acked-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:30:10 +08:00
Binbin Zhou
347afc58d3
dt-bindings: pwm: Add Loongson PWM controller
...
Add Loongson PWM controller binding with DT schema format using
json-schema.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org >
Acked-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:30:09 +08:00
Binbin Zhou
4f7b9849fd
clk: clk-loongson2: Fix the number count of clk provider
...
Since commit 02fb4f008433 ("clk: clk-loongson2: Fix potential buffer
overflow in flexible-array member access"), the clk provider register is
failed.
The count of `clks_num` is shown below:
for (p = data; p->name; p++)
clks_num++;
In fact, `clks_num` represents the number of SoC clocks and should be
expressed as the maximum value of the clock binding id in use (p->id + 1).
Now we fix it to avoid the following error when trying to register a clk
provider:
[ 13.409595] of_clk_hw_onecell_get: invalid index 17
Cc: stable@vger.kernel.org
Cc: Gustavo A. R. Silva <gustavoars@kernel.org >
Fixes: 02fb4f008433 ("clk: clk-loongson2: Fix potential buffer overflow in flexible-array member access")
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://lore.kernel.org/r/82e43d89a9a6791129cf8ea14f4eeb666cd87be4.1736856470.git.zhoubinbin@loongson.cn
Signed-off-by: Stephen Boyd <sboyd@kernel.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:28:30 +08:00
Binbin Zhou
933f4fe94f
clk: clk-loongson2: Switch to use devm_clk_hw_register_fixed_rate_parent_data()
...
Since commit 706ae6446494 ("clk: fixed-rate: add
devm_clk_hw_register_fixed_rate_parent_data()"), we can use the
devm_clk_hw_register_fixed_rate_parent_data() helper and from then on
there is no need to manually unregister the fixed rate hw.
Since clk_hw_unregister_fixed_rate() was not called before, we also fix
the memory leak that was present.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://lore.kernel.org/r/8733a7485619bdb791de25201a3d7984d1849c9f.1736856470.git.zhoubinbin@loongson.cn
Signed-off-by: Stephen Boyd <sboyd@kernel.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:28:30 +08:00
Binbin Zhou
b32fef8b74
gpio: loongson: Fix Loongson-2K2000 ACPI GPIO register offset
...
Since commit 3feb70a61740 ("gpio: loongson: add more gpio chip
support"), the Loongson-2K2000 GPIO is supported.
However, according to the firmware development specification, the
Loongson-2K2000 ACPI GPIO register offsets in the driver do not match
the register base addresses in the firmware, resulting in the registers
not being accessed properly.
Now, we fix it to ensure the GPIO function works properly.
Cc: stable@vger.kernel.org
Cc: Yinbo Zhu <zhuyinbo@loongson.cn >
Fixes: 3feb70a61740 ("gpio: loongson: add more gpio chip support")
Co-developed-by: Hongliang Wang <wanghongliang@loongson.cn >
Signed-off-by: Hongliang Wang <wanghongliang@loongson.cn >
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://lore.kernel.org/r/20250107103856.1037222-1-zhoubinbin@loongson.cn
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:28:29 +08:00
Binbin Zhou
45e00c1bea
dmaengine: loongson2-apb: Change GENMASK to GENMASK_ULL
...
Fix the following smatch static checker warning:
drivers/dma/loongson2-apb-dma.c:189 ls2x_dma_write_cmd()
warn: was expecting a 64 bit value instead of '~(((0)) + (((~((0))) - (((1)) << (0)) + 1) & (~((0)) >> ((8 * 4) - 1 - (4)))))'
The GENMASK macro used "unsigned long", which caused build issues when
using a 32-bit toolchain because it would try to access bits > 31. This
patch switches GENMASK to GENMASK_ULL, which uses "unsigned long long".
Fixes: 71e7d3cb6e55 ("dmaengine: ls2x-apb: New driver for the Loongson LS2X APB DMA controller")
Reported-by: Dan Carpenter <dan.carpenter@linaro.org >
Closes: https://lore.kernel.org/all/87cdc025-7246-4548-85ca-3d36fdc2be2d@stanley.mountain/
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://lore.kernel.org/r/20241028093413.1145820-1-zhoubinbin@loongson.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org >
Signed-off-by: michael <michael5hzg@gmail.com >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:26:46 +08:00
Binbin Zhou
22bbe4ea93
dmaengine: loongson2-apb: Rename the prefix ls2x to loongson2
...
Since commit e06c43231214 ("dmaengine: Loongson1: Add Loongson-1 APB DMA
driver"), the Loongson-1 dma controller was added.
Unfortunately their naming has not been standardized, as CPUs belonging
to the same Loongson family, we expect to standardize the naming for
ease of understanding.
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Link: https://lore.kernel.org/r/20240924064241.2414629-1-zhoubinbin@loongson.cn
Signed-off-by: Vinod Koul <vkoul@kernel.org >
Signed-off-by: michael <michael5hzg@gmail.com >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:26:45 +08:00
Binbin Zhou
8bd2373bda
LoongArch: dts: Add I2S support to Loongson-2K2000
...
The module is supported, adding it.
Not all Loongson-2K1000 boards have an i2s interface, here is an example
of enabling it:
sound {
compatible = "loongson,ls-audio-card";
model = "Loongson-ASoC";
mclk-fs = <512>;
cpu {
sound-dai = <&i2s>;
};
codec {
sound-dai = <&es8323>;
};
};
&i2c1 {
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
es8323:es8323@10 {
compatible = "everest,es8323";
reg = <0x10>;
#sound-dai-cells = <0>;
};
};
&i2s {
status = "okay";
clock-frequency = <175000000>;
#sound-dai-cells = <0>;
};
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: michael <michael5hzg@gmail.com >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:26:44 +08:00
Binbin Zhou
e5fbcbdeac
LoongArch: dts: Add I2S support to Loongson-2K1000
...
The module is supported, adding it.
Not all Loongson-2K1000 boards have an i2s interface, here is an example
of enabling it:
sound {
compatible = "loongson,ls-audio-card";
model = "Loongson-ASoC";
mclk-fs = <512>;
cpu {
sound-dai = <&i2s>;
};
codec {
sound-dai = <&uda1342>;
};
};
&apbdma2 {
status = "okay";
};
&apbdma3 {
status = "okay";
};
&i2c3 {
status = "okay";
pinctrl-0 = <&i2c1_pins_default>;
pinctrl-names = "default";
#address-cells = <1>;
#size-cells = <0>;
uda1342: codec@1a {
compatible = "nxp,uda1342";
reg = <0x1a>;
#sound-dai-cells = <0>;
};
};
&i2s {
status = "okay";
pinctrl-0 = <&hda_pins_default>;
pinctrl-names = "default";
};
Signed-off-by: Binbin Zhou <zhoubinbin@loongson.cn >
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn >
Signed-off-by: michael <michael5hzg@gmail.com >
Signed-off-by: maoxiaochuan <maoxiaochuan@loongson.cn >
2025-02-13 14:26:44 +08:00