Hi Punit,
Great to see PWM driver working
Besides Martin has suggested, I would like to add few points.
On 21 June 2016 at 21:56, Punit Vara wrote:
> This patch adds required definitions, registers definitions and
> testsuit to
> test pwm driver for beagle bone black.
> ---
> c/src/lib/libbsp/arm/beagle/Makefile.am | 3 +
> c/src/lib/libbsp/arm/beagle/pwm/bbb-pwm.c| 345
> ++
> c/src/lib/libbsp/shared/include/gpio.h | 11 +
> c/src/lib/libcpu/arm/shared/include/am335x.h | 349
> ++-
> testsuites/samples/Makefile.am | 2 +-
> testsuites/samples/configure.ac | 1 +
> testsuites/samples/pwm/Makefile.am | 19 ++
> testsuites/samples/pwm/init.c| 70 ++
> testsuites/samples/pwm/pwm.doc | 9 +
> testsuites/samples/pwm/pwm.scn | 3 +
> 10 files changed, 810 insertions(+), 2 deletions(-)
> create mode 100644 c/src/lib/libbsp/arm/beagle/pwm/bbb-pwm.c
> create mode 100644 testsuites/samples/pwm/Makefile.am
> create mode 100644 testsuites/samples/pwm/init.c
> create mode 100644 testsuites/samples/pwm/pwm.doc
> create mode 100644 testsuites/samples/pwm/pwm.scn
>
> diff --git a/c/src/lib/libbsp/arm/beagle/Makefile.am
> b/c/src/lib/libbsp/arm/beagle/Makefile.am
> index 20d3092..68bdbd4 100644
> --- a/c/src/lib/libbsp/arm/beagle/Makefile.am
> +++ b/c/src/lib/libbsp/arm/beagle/Makefile.am
> @@ -117,6 +117,9 @@ libbsp_a_SOURCES += misc/i2c.c
> # GPIO
> libbsp_a_SOURCES += gpio/bbb-gpio.c
>
> +#pwm
> +libbsp_a_SOURCES += pwm/bbb-pwm.c
> +
> #RTC
> libbsp_a_SOURCES += rtc.c
> libbsp_a_SOURCES += ../../shared/tod.c
> diff --git a/c/src/lib/libbsp/arm/beagle/pwm/bbb-pwm.c
> b/c/src/lib/libbsp/arm/beagle/pwm/bbb-pwm.c
> new file mode 100644
> index 000..a2f1107
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/beagle/pwm/bbb-pwm.c
> @@ -0,0 +1,345 @@
> +/* This file is based on following licence
> + * Copyright (c) 2015, Shabaz, VegetableAvenger
> + * Copyright (c) 2016, Punit Vara
> + * Added clock functions and improved pwm_enable function
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms, with or without
> + * modification, are permitted provided that the following conditions are
> met:
> + *
> + * Redistributions of source code must retain the above copyright notice,
> this
> + * list of conditions and the following disclaimer.
> +
> + * Redistributions in binary form must reproduce the above copyright
> notice,
> + * this list of conditions and the following disclaimer in the
> documentation
> + * and/or other materials provided with the distribution.
> + *
> + * Neither the name of BBBIOlib nor the names of its
> + * contributors may be used to endorse or promote products derived from
> + * this software without specific prior written permission.
> + *
> + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
> "AS IS"
> + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
> THE
> + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
> PURPOSE ARE
> + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
> LIABLE
> + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
> CONSEQUENTIAL
> + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
> GOODS OR
> + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
> HOWEVER
> + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
> LIABILITY,
> + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
> THE USE
> + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> + */
> +
> +#include
> +#include
> +#include
> +#include
> +#include
> +
> +#define BASE_CLOCK 1
> +/**
> + * @brief This function intilize clock and pinmuxing for pwm sub system.
> + *
> + * @param PWMSS_ID It is the instance number of EPWM of pwm sub system.
> + **/
> +void pwm_init(unsigned int baseAddr, unsigned int PWMSS_ID)
> +{
> + module_clk_config(PWMSS_ID);
> + EPWMPinMuxSetup();
> + EPWM_clock_enable(baseAddr);
> + pwmss_tbclk_enable(PWMSS_ID);
> +
> +}
> +
> +
> +/**
> + * \brief This function Enables TBCLK(Time Base Clock) for specific
> + * EPWM instance of pwmsubsystem.
> + *
> + * \param instance It is the instance number of EPWM of pwmsubsystem.
> + *
> + **/
> +void pwmss_tbclk_enable(unsigned int instance)
> +{
> + switch(instance)
> + {
> +
> + case 0:
> + REG(AM335X_PADCONF_BASE + CONTROL_PWMSS_CTRL) |=
> + BBBIO_PWMSS_CTRL_PWMSS0_TBCLKEN;
> + break;
> +
> + case 1:
> + REG(AM335X_PADCONF_BASE + CONTROL_PWMSS_CTRL) |=
> + BBBIO_PWMSS_CTRL_PWMSS1_TBCLKEN;
> + break;
> +
> + case 2: