SAMA5D2 Xplained config tcb1 as pwm

Moderator: nferre

sanduo
Posts: 7
Joined: Fri Oct 05, 2018 6:30 am

SAMA5D2 Xplained config tcb1 as pwm

Wed Mar 27, 2019 5:41 am

Hi all,

I tried to config timer counter block 1 work as pwm.
But no any pwm signal detected from those 4 pins I configured.
I checked debug info, pins are configured and driver detected the device, timer clock's enabled.

I would appreciate if anyone can help me out here :) .

Buildroot: 2018.02
Board: SAMA5D2 Xplained
Uboot: linux4sam_6.0
Linux: linux4sam_6.0
At91bootstrap: 3.8.11

DTS:

Code: Select all

...
apb {
 ...
    tcb1: timer@f8010000 {
                tcb1_pwm {
                    compatible = "atmel,tcb-pwm";
                    #pwm-cells = <3>;
                    tc-block = <1>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&pinctrl_tcb1_tioa3
                                &pinctrl_tcb1_tiob3
                                &pinctrl_tcb1_tioa4
                                &pinctrl_tcb1_tiob4>;
                    status = "okay";
                };
            };

pinctrl@fc038000 {
 ...
         pinctrl_tcb1_tioa3: tcb1_tioa3 {
                    pinmux = <PIN_PD29__TIOA3>;
                    bias-pull-up;
                };

                pinctrl_tcb1_tiob3: tcb1_tiob3 {
                    pinmux = <PIN_PD30__TIOB3>;
                    bias-pull-up;
                };

                pinctrl_tcb1_tioa4: tcb1_tioa4 {
                    pinmux = <PIN_PC9__TIOA4>;
                    bias-pull-up;
                };

                pinctrl_tcb1_tiob4: tcb1_tiob4 {
                    pinmux = <PIN_PC10__TIOB4>;
                    bias-pull-up;
                };
};
# cat /sys/kernel/debug/pwm
platform/f8010000.timer:tcb1_pwm, 6 PWM devices
pwm-0 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
pwm-1 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
pwm-2 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
pwm-3 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
pwm-4 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
pwm-5 (sysfs ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse

# cat /sys/kernel/debug/pinctrl/fc038000.pinctrl/pinmux-pins
...
pin 73 (PC9): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PC9
pin 74 (PC10): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PC10
...
pin 125 (PD29): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PD29
pin 126 (PD30): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PD30
...

# devmem 0xF0014108
0x00088258

#find /sys/ -iname "*tcb*"
...
/sys/firmware/devicetree/base/ahb/apb/timer@f8010000/tcb1_pwm
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/tcb1_tiob3
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/tcb1_tioa3
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/tcb1_tiob4
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/tcb1_tioa4
/sys/bus/platform/devices/f8010000.timer:tcb1_pwm
/sys/bus/platform/drivers/atmel-tcb-pwm
/sys/bus/platform/drivers/atmel-tcb-pwm/f8010000.timer:tcb1_pwm
/sys/bus/platform/drivers/atmel_tcb
Thanks.
blue_z
Location: USA
Posts: 1943
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 Xplained config tcb1 as pwm

Wed Mar 27, 2019 9:59 pm

sanduo wrote:
# cat /sys/kernel/debug/pinctrl/fc038000.pinctrl/pinmux-pins
...
pin 73 (PC9): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PC9
pin 74 (PC10): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PC10
...
pin 125 (PD29): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PD29
pin 126 (PD30): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PD30
...
I'm not sure if there's anything else improper with your DT, but your choice of pin assignments is not valid.
Pins PC9 and PC10 using function D belong to IOset 2.
Pins PD29 and PD30 using function D belong to IOset 3.
You cannot use pins of different IOsets on a peripheral.
Refer to the note in section 6.2 in the SoC datasheet.

Regards
sanduo
Posts: 7
Joined: Fri Oct 05, 2018 6:30 am

Re: SAMA5D2 Xplained config tcb1 as pwm

Wed Mar 27, 2019 11:47 pm

Thank you blue_z.
I modified my dts to just keep pin PD30 as tcb pwm, but it still has no signal.

Code: Select all

/*
 * at91-sama5d2_xplained.dts - Device Tree file for SAMA5D2 Xplained board
 *
 *  Copyright (C) 2015 Atmel,
 *                2015 Nicolas Ferre <nicolas.ferre@atmel.com>
 *
 * This file is dual-licensed: you can use it either under the terms
 * of the GPL or the X11 license, at your option. Note that this dual
 * licensing only applies to this file, and not this project as a
 * whole.
 *
 *  a) This file is free software; you can redistribute it and/or
 *     modify it under the terms of the GNU General Public License as
 *     published by the Free Software Foundation; either version 2 of the
 *     License, or (at your option) any later version.
 *
 *     This file is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 * Or, alternatively,
 *
 *  b) Permission is hereby granted, free of charge, to any person
 *     obtaining a copy of this software and associated documentation
 *     files (the "Software"), to deal in the Software without
 *     restriction, including without limitation the rights to use,
 *     copy, modify, merge, publish, distribute, sublicense, and/or
 *     sell copies of the Software, and to permit persons to whom the
 *     Software is furnished to do so, subject to the following
 *     conditions:
 *
 *     The above copyright notice and this permission notice shall be
 *     included in all copies or substantial portions of the Software.
 *
 *     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 *     EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 *     OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 *     NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 *     HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 *     WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 *     OTHER DEALINGS IN THE SOFTWARE.
 */
/dts-v1/;
#include "sama5d2.dtsi"
#include "sama5d2-pinfunc.h"
#include <dt-bindings/mfd/atmel-flexcom.h>
#include <dt-bindings/gpio/gpio.h>

/ {
	model = "Atmel SAMA5D2 Xplained";
	compatible = "atmel,sama5d2-xplained", "atmel,sama5d2", "atmel,sama5";

	chosen {
		stdout-path = "serial0:115200n8";
	};

	clocks {
		slow_xtal {
			clock-frequency = <32768>;
		};

		main_xtal {
			clock-frequency = <12000000>;
		};
	};

	ahb {
		usb0: gadget@300000 {
			status = "okay";
		};

        usb1: ohci@400000 {
            status = "okay";
        };

		usb2: ehci@500000 {
			status = "okay";
		};

		sdmmc0: sdio-host@a0000000 {
			bus-width = <8>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sdmmc0_default>;
			non-removable;
			mmc-ddr-1_8v;
			status = "okay";
		};

		sdmmc1: sdio-host@b0000000 {
			bus-width = <4>;
			pinctrl-names = "default";
			pinctrl-0 = <&pinctrl_sdmmc1_default>;
			status = "okay"; /* conflict with qspi0 */
		};

		apb {
			pmc: pmc@f0014000 {
				pmc_fast_restart {
					compatible = "atmel,sama5d2-pmc-fast-startup";
					#address-cells = <1>;
					#size-cells = <0>;

					atmel,wakeup-rtc-timer;

					wkpin: input@0 {
						reg = <0>;
					};

					gmac_wol: input@10 {
						reg = <10>;
						atmel,wakeup-active-high;
					};
				};
			};

			qspi1: spi@f0024000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_qspi1_default>;
				status = "okay";

				flash@0 {
					#address-cells = <1>;
					#size-cells = <1>;
					compatible = "jedec,spi-nor";
					reg = <0>;
					spi-max-frequency = <83000000>;
					m25p,fast-read;

					at91bootstrap@00000000 {
						label = "at91bootstrap";
						reg = <0x00000000 0x00010000>;
					};

					bootloaderenv@00010000 {
						label = "bootloader env";
						reg = <0x00010000 0x00010000>;
					};

					bootloader@00020000 {
						label = "bootloader";
						reg = <0x00020000 0x00050000>;
					};

					dtb@00070000 {
						label = "device tree";
						reg = <0x00070000 0x00010000>;
					};

					kernel@00080000 {
						label = "kernel";
						reg = <0x00080000 0x00380000>;
					};

					rootfs@00400000 {
						label = "rootfs";
						reg = <0x00400000 0x00000000>;
					};
				};
			};

			macb0: ethernet@f8008000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_macb0_default &pinctrl_macb0_phy_irq>;
				phy-mode = "rmii";
				status = "okay";

				ethernet-phy@1 {
					reg = <0x1>;
					interrupt-parent = <&pioA>;
					interrupts = <PIN_PD31 IRQ_TYPE_LEVEL_LOW>;
				};
			};

            tcb0: timer@f800c000 {
				timer0: timer@0 {
					compatible = "atmel,tcb-timer";
					reg = <0>;
				};

				timer1: timer@1 {
					compatible = "atmel,tcb-timer";
					reg = <1>;
				};
			};

            tcb1: timer@f8010000 {
                tcb1_pwm {
                    compatible = "atmel,tcb-pwm";
                    #pwm-cells = <3>;
                    tc-block = <1>;
                    pinctrl-names = "default";
                    pinctrl-0 = <&pinctrl_tcb1_tiob3>;
                    status = "okay";
                };
            };

			uart1: serial@f8020000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_uart1_default>;
				atmel,use-dma-rx;
				atmel,use-dma-tx;
				status = "okay";
			};

            i2c0: i2c@f8028000 {
				dmas = <0>, <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_i2c0_default>;
				i2c-sda-hold-time-ns = <350>;
				status = "okay";
            };

			flx0: flexcom@f8034000 {
				atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_USART>;
				status = "disabled"; /* conflict with ISC_D2 & ISC_D3 data pins */

				uart5: serial@200 {
					compatible = "atmel,at91sam9260-usart";
					reg = <0x200 0x200>;
					interrupts = <19 IRQ_TYPE_LEVEL_HIGH 7>;
					clocks = <&flx0_clk>;
					clock-names = "usart";
					pinctrl-names = "default";
					pinctrl-0 = <&pinctrl_flx0_default>;
					atmel,fifo-size = <32>;
					status = "okay";
				};
			};

			shdwc@f8048010 {
				atmel,shdwc-debouncer = <976>;
				atmel,wakeup-rtc-timer;

				input@0 {
					reg = <0>;
					atmel,wakeup-type = "low";
				};
			};

			watchdog@f8048040 {
				status = "okay";
			};

			can0: can@f8054000 {
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_can0_default>;
                status = "okay";
			};

			uart3: serial@fc008000 {
				atmel,use-dma-rx;
				atmel,use-dma-tx;
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_uart3_default>;
				status = "okay";
			};

			flx4: flexcom@fc018000 {
				atmel,flexcom-mode = <ATMEL_FLEXCOM_MODE_TWI>;
				status = "okay";

				i2c2: i2c@600 {
					compatible = "atmel,sama5d2-i2c";
					reg = <0x600 0x200>;
					interrupts = <23 IRQ_TYPE_LEVEL_HIGH 7>;
					dmas = <0>, <0>;
					dma-names = "tx", "rx";
					#address-cells = <1>;
					#size-cells = <0>;
					clocks = <&flx4_clk>;
					pinctrl-names = "default";
					pinctrl-0 = <&pinctrl_flx4_default>;
					atmel,fifo-size = <16>;
					status = "okay";
				};
			};

			i2c1: i2c@fc028000 {
				dmas = <0>, <0>;
				pinctrl-names = "default";
				pinctrl-0 = <&pinctrl_i2c1_default>;
				status = "okay";

				at24@54 {
					compatible = "atmel,24c02";
					reg = <0x54>;
					pagesize = <16>;
				};
			};

			adc: adc@fc030000 {
				status = "disabled";
			};

			pinctrl@fc038000 {
				pinctrl_can0_default: can0_default {
					pinmux = <PIN_PC1__CANTX0>,
						 <PIN_PC2__CANRX0>;
					bias-disable;
				};

				pinctrl_flx0_default: flx0_default {
					pinmux = <PIN_PB28__FLEXCOM0_IO0>,
						 <PIN_PB29__FLEXCOM0_IO1>;
					bias-disable;
				};

				pinctrl_flx4_default: flx4_default {
					pinmux = <PIN_PC28__FLEXCOM4_IO0>,
						 <PIN_PC29__FLEXCOM4_IO1>;
					bias-disable;
				};

                pinctrl_i2c0_default: i2c0_default {
					pinmux = <PIN_PD21__TWD0>,
						 <PIN_PD22__TWCK0>;
					bias-disable;
				};

				pinctrl_i2c1_default: i2c1_default {
					pinmux = <PIN_PC6__TWD1>,
						 <PIN_PC7__TWCK1>;
					bias-disable;
				};

				pinctrl_led_gpio_default: led_gpio_default {
					pinmux = <PIN_PA23__GPIO>;
					bias-pull-up;
				};

				pinctrl_macb0_default: macb0_default {
					pinmux = <PIN_PB14__GTXCK>,
						 <PIN_PB15__GTXEN>,
						 <PIN_PB16__GRXDV>,
						 <PIN_PB17__GRXER>,
						 <PIN_PB18__GRX0>,
						 <PIN_PB19__GRX1>,
						 <PIN_PB20__GTX0>,
						 <PIN_PB21__GTX1>,
						 <PIN_PB22__GMDC>,
						 <PIN_PB23__GMDIO>;
					bias-disable;
				};

				pinctrl_macb0_phy_irq: macb0_phy_irq {
					pinmux = <PIN_PD31__IRQ>;
					bias-disable;
				};

				pinctrl_qspi1_default: qspi1_default {
					sck_cs {
						pinmux = <PIN_PB5__QSPI1_SCK>,
							 <PIN_PB6__QSPI1_CS>;
						bias-disable;
					};

					data {
						pinmux = <PIN_PB7__QSPI1_IO0>,
							 <PIN_PB8__QSPI1_IO1>,
							 <PIN_PB9__QSPI1_IO2>,
							 <PIN_PB10__QSPI1_IO3>;
						bias-pull-up;
					};
				};

				pinctrl_sdmmc0_default: sdmmc0_default {
					cmd_data {
						pinmux = <PIN_PA1__SDMMC0_CMD>,
							 <PIN_PA2__SDMMC0_DAT0>,
							 <PIN_PA3__SDMMC0_DAT1>,
							 <PIN_PA4__SDMMC0_DAT2>,
							 <PIN_PA5__SDMMC0_DAT3>,
							 <PIN_PA6__SDMMC0_DAT4>,
							 <PIN_PA7__SDMMC0_DAT5>,
							 <PIN_PA8__SDMMC0_DAT6>,
							 <PIN_PA9__SDMMC0_DAT7>;
						bias-disable;
					};

					ck_cd_rstn_vddsel {
						pinmux = <PIN_PA0__SDMMC0_CK>,
							 <PIN_PA10__SDMMC0_RSTN>,
							 <PIN_PA13__SDMMC0_CD>;
						bias-disable;
					};
				};

				pinctrl_sdmmc1_default: sdmmc1_default {
					cmd_data {
						pinmux = <PIN_PA28__SDMMC1_CMD>,
							 <PIN_PA18__SDMMC1_DAT0>,
							 <PIN_PA19__SDMMC1_DAT1>,
							 <PIN_PA20__SDMMC1_DAT2>,
							 <PIN_PA21__SDMMC1_DAT3>;
						bias-disable;
					};

					conf-ck_cd {
						pinmux = <PIN_PA22__SDMMC1_CK>,
							 <PIN_PA30__SDMMC1_CD>;
						bias-disable;
					};
				};

				pinctrl_uart0_default: uart0_default {
					pinmux = <PIN_PB26__URXD0>,
						 <PIN_PB27__UTXD0>;
					bias-disable;
				};

				pinctrl_uart1_default: uart1_default {
					pinmux = <PIN_PD2__URXD1>,
						 <PIN_PD3__UTXD1>;
					bias-disable;
				};

				pinctrl_uart2_default: uart2_default {
					pinmux = <PIN_PD19__URXD2>,
						 <PIN_PD20__UTXD2>;
					bias-disable;
				};

				pinctrl_uart3_default: uart3_default {
					pinmux = <PIN_PC31__URXD3>,
						 <PIN_PD0__UTXD3>;
					bias-disable;
				};

				pinctrl_uart4_default: uart4_default {
					pinmux = <PIN_PB3__URXD4>,
						 <PIN_PB4__UTXD4>;
					bias-disable;
				};

                pinctrl_tcb1_tiob3: tcb1_tiob3 {
                    pinmux = <PIN_PD30__TIOB3>;
                    bias-pull-up;
                };
			};
		};
	};

	leds {
		compatible = "gpio-leds";
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_led_gpio_default>;
		status = "okay";

		heartbeat {
			label = "heartbeat";
			gpios = <&pioA PIN_PA23 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "heartbeat";
		};
	};
};
debug info

Code: Select all

# cat /sys/kernel/debug/pwm
platform/f8010000.timer:tcb1_pwm, 6 PWM devices
 pwm-0   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
 pwm-1   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
 pwm-2   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
 pwm-3   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
 pwm-4   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse
 pwm-5   (sysfs               ): requested enabled period: 500000000 ns duty: 250000000 ns polarity: inverse

platform/f802c000.pwm, 4 PWM devices
 pwm-0   (sysfs               ): requested enabled period: 1000000 ns duty: 500000 ns polarity: normal
 pwm-1   (sysfs               ): requested enabled period: 1000000 ns duty: 500000 ns polarity: normal
 pwm-2   (sysfs               ): requested enabled period: 1000000 ns duty: 500000 ns polarity: normal
 pwm-3   (sysfs               ): requested enabled period: 1000000 ns duty: 500000 ns polarity: normal
# cat /sys/kernel/debug/pinctrl/fc038000.pinctrl/pinmux-pins
Pinmux settings per pin
Format: pin (name): mux_owner gpio_owner hog?
pin 0 (PA0): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA0
pin 1 (PA1): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA1
pin 2 (PA2): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA2
pin 3 (PA3): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA3
pin 4 (PA4): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA4
pin 5 (PA5): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA5
pin 6 (PA6): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA6
pin 7 (PA7): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA7
pin 8 (PA8): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA8
pin 9 (PA9): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA9
pin 10 (PA10): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA10
pin 11 (PA11): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 12 (PA12): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 13 (PA13): a0000000.sdio-host (GPIO UNCLAIMED) function A group PA13
pin 14 (PA14): (MUX UNCLAIMED) fc038000.pinctrl:14
pin 15 (PA15): (MUX UNCLAIMED) fc038000.pinctrl:15
pin 16 (PA16): (MUX UNCLAIMED) fc038000.pinctrl:16
pin 17 (PA17): (MUX UNCLAIMED) fc038000.pinctrl:17
pin 18 (PA18): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA18
pin 19 (PA19): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA19
pin 20 (PA20): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA20
pin 21 (PA21): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA21
pin 22 (PA22): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA22
pin 23 (PA23): leds fc038000.pinctrl:23 function GPIO group PA23
pin 24 (PA24): (MUX UNCLAIMED) fc038000.pinctrl:24
pin 25 (PA25): (MUX UNCLAIMED) fc038000.pinctrl:25
pin 26 (PA26): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 27 (PA27): (MUX UNCLAIMED) fc038000.pinctrl:27
pin 28 (PA28): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA28
pin 29 (PA29): (MUX UNCLAIMED) fc038000.pinctrl:29
pin 30 (PA30): b0000000.sdio-host (GPIO UNCLAIMED) function E group PA30
pin 31 (PA31): (MUX UNCLAIMED) fc038000.pinctrl:31
pin 32 (PB0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 33 (PB1): (MUX UNCLAIMED) fc038000.pinctrl:33
pin 34 (PB2): (MUX UNCLAIMED) fc038000.pinctrl:34
pin 35 (PB3): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 36 (PB4): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 37 (PB5): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 38 (PB6): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 39 (PB7): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 40 (PB8): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 41 (PB9): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 42 (PB10): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 43 (PB11): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 44 (PB12): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 45 (PB13): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 46 (PB14): f8008000.ethernet (GPIO UNCLAIMED) function F group PB14
pin 47 (PB15): f8008000.ethernet (GPIO UNCLAIMED) function F group PB15
pin 48 (PB16): f8008000.ethernet (GPIO UNCLAIMED) function F group PB16
pin 49 (PB17): f8008000.ethernet (GPIO UNCLAIMED) function F group PB17
pin 50 (PB18): f8008000.ethernet (GPIO UNCLAIMED) function F group PB18
pin 51 (PB19): f8008000.ethernet (GPIO UNCLAIMED) function F group PB19
pin 52 (PB20): f8008000.ethernet (GPIO UNCLAIMED) function F group PB20
pin 53 (PB21): f8008000.ethernet (GPIO UNCLAIMED) function F group PB21
pin 54 (PB22): f8008000.ethernet (GPIO UNCLAIMED) function F group PB22
pin 55 (PB23): f8008000.ethernet (GPIO UNCLAIMED) function F group PB23
pin 56 (PB24): (MUX UNCLAIMED) fc038000.pinctrl:56
pin 57 (PB25): (MUX UNCLAIMED) fc038000.pinctrl:57
pin 58 (PB26): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 59 (PB27): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 60 (PB28): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 61 (PB29): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 62 (PB30): (MUX UNCLAIMED) fc038000.pinctrl:62
pin 63 (PB31): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 64 (PC0): (MUX UNCLAIMED) fc038000.pinctrl:64
pin 65 (PC1): f8054000.can (GPIO UNCLAIMED) function C group PC1
pin 66 (PC2): f8054000.can (GPIO UNCLAIMED) function C group PC2
pin 67 (PC3): (MUX UNCLAIMED) fc038000.pinctrl:67
pin 68 (PC4): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 69 (PC5): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 70 (PC6): fc028000.i2c (GPIO UNCLAIMED) function C group PC6
pin 71 (PC7): fc028000.i2c (GPIO UNCLAIMED) function C group PC7
pin 72 (PC8): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 73 (PC9): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 74 (PC10): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 75 (PC11): (MUX UNCLAIMED) fc038000.pinctrl:75
pin 76 (PC12): (MUX UNCLAIMED) fc038000.pinctrl:76
pin 77 (PC13): (MUX UNCLAIMED) fc038000.pinctrl:77
pin 78 (PC14): (MUX UNCLAIMED) fc038000.pinctrl:78
pin 79 (PC15): (MUX UNCLAIMED) fc038000.pinctrl:79
pin 80 (PC16): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 81 (PC17): (MUX UNCLAIMED) fc038000.pinctrl:81
pin 82 (PC18): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 83 (PC19): (MUX UNCLAIMED) fc038000.pinctrl:83
pin 84 (PC20): (MUX UNCLAIMED) fc038000.pinctrl:84
pin 85 (PC21): (MUX UNCLAIMED) fc038000.pinctrl:85
pin 86 (PC22): (MUX UNCLAIMED) fc038000.pinctrl:86
pin 87 (PC23): (MUX UNCLAIMED) fc038000.pinctrl:87
pin 88 (PC24): (MUX UNCLAIMED) fc038000.pinctrl:88
pin 89 (PC25): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 90 (PC26): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 91 (PC27): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 92 (PC28): fc018600.i2c (GPIO UNCLAIMED) function B group PC28
pin 93 (PC29): fc018600.i2c (GPIO UNCLAIMED) function B group PC29
pin 94 (PC30): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 95 (PC31): fc008000.serial (GPIO UNCLAIMED) function C group PC31
pin 96 (PD0): fc008000.serial (GPIO UNCLAIMED) function C group PD0
pin 97 (PD1): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 98 (PD2): f8020000.serial (GPIO UNCLAIMED) function A group PD2
pin 99 (PD3): f8020000.serial (GPIO UNCLAIMED) function A group PD3
pin 100 (PD4): (MUX UNCLAIMED) fc038000.pinctrl:100
pin 101 (PD5): (MUX UNCLAIMED) fc038000.pinctrl:101
pin 102 (PD6): (MUX UNCLAIMED) fc038000.pinctrl:102
pin 103 (PD7): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 104 (PD8): (MUX UNCLAIMED) fc038000.pinctrl:104
pin 105 (PD9): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 106 (PD10): (MUX UNCLAIMED) fc038000.pinctrl:106
pin 107 (PD11): (MUX UNCLAIMED) fc038000.pinctrl:107
pin 108 (PD12): (MUX UNCLAIMED) fc038000.pinctrl:108
pin 109 (PD13): (MUX UNCLAIMED) fc038000.pinctrl:109
pin 110 (PD14): (MUX UNCLAIMED) fc038000.pinctrl:110
pin 111 (PD15): (MUX UNCLAIMED) fc038000.pinctrl:111
pin 112 (PD16): (MUX UNCLAIMED) fc038000.pinctrl:112
pin 113 (PD17): (MUX UNCLAIMED) fc038000.pinctrl:113
pin 114 (PD18): (MUX UNCLAIMED) fc038000.pinctrl:114
pin 115 (PD19): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 116 (PD20): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 117 (PD21): f8028000.i2c (GPIO UNCLAIMED) function B group PD21
pin 118 (PD22): f8028000.i2c (GPIO UNCLAIMED) function B group PD22
pin 119 (PD23): (MUX UNCLAIMED) fc038000.pinctrl:119
pin 120 (PD24): (MUX UNCLAIMED) fc038000.pinctrl:120
pin 121 (PD25): (MUX UNCLAIMED) fc038000.pinctrl:121
pin 122 (PD26): (MUX UNCLAIMED) fc038000.pinctrl:122
pin 123 (PD27): (MUX UNCLAIMED) fc038000.pinctrl:123
pin 124 (PD28): (MUX UNCLAIMED) fc038000.pinctrl:124
pin 125 (PD29): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 126 (PD30): f8010000.timer:tcb1_pwm (GPIO UNCLAIMED) function D group PD30
pin 127 (PD31): f8008000.ethernet (GPIO UNCLAIMED) function C group PD31
# find /sys/ -iname "*tcb*"
/sys/kernel/debug/clk/tcb0_clk
/sys/kernel/debug/clk/tcb1_clk
/sys/kernel/debug/clk/tcb0_gclk
/sys/kernel/debug/clk/tcb1_gclk
/sys/devices/platform/ahb/ahb:apb/f8010000.timer/f8010000.timer:tcb1_pwm
/sys/firmware/devicetree/base/__symbols__/pinctrl_tcb1_tiob3
/sys/firmware/devicetree/base/__symbols__/tcb0
/sys/firmware/devicetree/base/__symbols__/tcb1
/sys/firmware/devicetree/base/__symbols__/tcb0_clk
/sys/firmware/devicetree/base/__symbols__/tcb1_gclk
/sys/firmware/devicetree/base/__symbols__/tcb1_clk
/sys/firmware/devicetree/base/__symbols__/tcb0_gclk
/sys/firmware/devicetree/base/aliases/tcb0
/sys/firmware/devicetree/base/aliases/tcb1
/sys/firmware/devicetree/base/ahb/apb/pmc@f0014000/gck/tcb1_gclk
/sys/firmware/devicetree/base/ahb/apb/pmc@f0014000/gck/tcb0_gclk
/sys/firmware/devicetree/base/ahb/apb/pmc@f0014000/periph32ck/tcb0_clk
/sys/firmware/devicetree/base/ahb/apb/pmc@f0014000/periph32ck/tcb1_clk
/sys/firmware/devicetree/base/ahb/apb/timer@f8010000/tcb1_pwm
/sys/firmware/devicetree/base/ahb/apb/pinctrl@fc038000/tcb1_tiob3
/sys/bus/platform/devices/f8010000.timer:tcb1_pwm
/sys/bus/platform/drivers/atmel-tcb-pwm
/sys/bus/platform/drivers/atmel-tcb-pwm/f8010000.timer:tcb1_pwm
/sys/bus/platform/drivers/atmel_tcb
#
blue_z
Location: USA
Posts: 1943
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 Xplained config tcb1 as pwm

Thu Mar 28, 2019 12:29 am

Have you tried changing the channel parameters through sysfs?
See the PWM FAQ.

Regards
sanduo
Posts: 7
Joined: Fri Oct 05, 2018 6:30 am

Re: SAMA5D2 Xplained config tcb1 as pwm

Thu Mar 28, 2019 1:54 am

I've tried to change parameters through sys (pwm0-5, period, duty, polarity). but pin PD30 still no any signal.
I'm afraid I missing config something, do I need to config clock source for timer counter block1 or direction or anything else?

Thank you very much:)
blue_z
Location: USA
Posts: 1943
Joined: Thu Apr 19, 2007 10:15 pm

Re: SAMA5D2 Xplained config tcb1 as pwm

Thu Mar 28, 2019 8:16 am

There is one example of an Atmel TCB in PWM mode, arch/arm/boot/dts/at91-kizbox.dts with arch/arm/boot/dts/at91sam9260.dtsi, in the kernel source code.
The salient nodes and properties from that example are:

Code: Select all

/ {
        ahb {
                apb {

			tcb1: timer@fffdc000 {
				compatible = "atmel,at91rm9200-tcb", "simple-mfd", "syscon";
				#address-cells = <1>;
				#size-cells = <0>;
				reg = <0xfffdc000 0x100>;
				interrupts = <26 IRQ_TYPE_LEVEL_HIGH 0
					      27 IRQ_TYPE_LEVEL_HIGH 0
					      28 IRQ_TYPE_LEVEL_HIGH 0>;
				clocks = <&tc3_clk>, <&tc4_clk>, <&tc5_clk>, <&clk32k>;
				clock-names = "t0_clk", "t1_clk", "t2_clk", "slow_clk";
			};

                        pinctrl: pinctrl@fffff400 {

                                tcb1 {
                                        pinctrl_tcb1_tclk0: tcb1_tclk0-0 { ...  };
                                        pinctrl_tcb1_tclk1: tcb1_tclk1-0  { ...  };
                                        pinctrl_tcb1_tclk2: tcb1_tclk2-0  { ...  };
                                        pinctrl_tcb1_tioa0: tcb1_tioa0-0  { ...  };
                                        pinctrl_tcb1_tioa1: tcb1_tioa1-0  { ...  };
                                        pinctrl_tcb1_tioa2: tcb1_tioa2-0  { ...  };
                                        pinctrl_tcb1_tiob0: tcb1_tiob0-0  { ...  };
                                        pinctrl_tcb1_tiob1: tcb1_tiob1-0  { ...  };
                                        pinctrl_tcb1_tiob2: tcb1_tiob2-0  { ...  };
                                };
                        };

                };
        };

        tcb_pwm: pwm {
                compatible = "atmel,tcb-pwm";
                #pwm-cells = <3>;
                tc-block = <1>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_tcb1_tioa0
                             &pinctrl_tcb1_tioa1
                             &pinctrl_tcb1_tioa2
                             &pinctrl_tcb1_tiob0>;
        };

};
Two salient differences between your DT and this SAM9G20 example are:
1. the pinctrl group for tcb1 defines all 9 pins of that TCB.
2. the tcb_pwm: pwm node is attached to the root node (i.e. just like your leds node), and not attached to the ahb or apb nodes.

Suggest you make similar adjustments to your DT (at least #2).

Regards
sanduo
Posts: 7
Joined: Fri Oct 05, 2018 6:30 am

Re: SAMA5D2 Xplained config tcb1 as pwm

Mon Apr 01, 2019 3:12 am

Sorted.
Default clock source is Gclk, has no signal.
After change to other clock source, I got pwm signal :D
Thank you very much!

Return to “SAMA5-based”

Who is online

Users browsing this forum: No registered users and 1 guest