Home | History | Annotate | Line # | Download | only in broadcom
      1  1.2    skrll /*	$NetBSD: bcm2835_pwm.h,v 1.2 2017/10/19 05:45:37 skrll Exp $	*/
      2  1.1  mlelstv 
      3  1.1  mlelstv /*-
      4  1.1  mlelstv  * Copyright (c) 2015 The NetBSD Foundation, Inc.
      5  1.1  mlelstv  * All rights reserved.
      6  1.1  mlelstv  *
      7  1.1  mlelstv  * Redistribution and use in source and binary forms, with or without
      8  1.1  mlelstv  * modification, are permitted provided that the following conditions
      9  1.1  mlelstv  * are met:
     10  1.1  mlelstv  * 1. Redistributions of source code must retain the above copyright
     11  1.1  mlelstv  *    notice, this list of conditions and the following disclaimer.
     12  1.1  mlelstv  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  mlelstv  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  mlelstv  *    documentation and/or other materials provided with the distribution.
     15  1.1  mlelstv  *
     16  1.1  mlelstv  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     17  1.1  mlelstv  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     18  1.1  mlelstv  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     19  1.1  mlelstv  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  1.1  mlelstv  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  1.1  mlelstv  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
     22  1.1  mlelstv  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  1.1  mlelstv  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  1.1  mlelstv  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     25  1.1  mlelstv  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  1.1  mlelstv  * SUCH DAMAGE.
     27  1.1  mlelstv  */
     28  1.1  mlelstv 
     29  1.1  mlelstv #ifndef BCM2835_PWMREG_H
     30  1.1  mlelstv #define BCM2835_PWMREG_H
     31  1.1  mlelstv 
     32  1.1  mlelstv #define PWM_CTL			0x00
     33  1.1  mlelstv #define  PWM_CTL_MSEN2		__BIT(15)
     34  1.1  mlelstv #define  PWM_CTL_USEF2		__BIT(13)
     35  1.1  mlelstv #define  PWM_CTL_POLA2		__BIT(12)
     36  1.1  mlelstv #define  PWM_CTL_SBIT2		__BIT(11)
     37  1.1  mlelstv #define  PWM_CTL_RPTL2		__BIT(10)
     38  1.1  mlelstv #define  PWM_CTL_MODE2		__BIT(9)
     39  1.1  mlelstv #define  PWM_CTL_PWEN2		__BIT(8)
     40  1.1  mlelstv #define  PWM_CTL_MSEN1		__BIT(7)
     41  1.1  mlelstv #define  PWM_CTL_CLRF1		__BIT(6)
     42  1.1  mlelstv #define  PWM_CTL_USEF1		__BIT(5)
     43  1.1  mlelstv #define  PWM_CTL_POLA1		__BIT(4)
     44  1.1  mlelstv #define  PWM_CTL_SBIT1		__BIT(3)
     45  1.1  mlelstv #define  PWM_CTL_RPTL1		__BIT(2)
     46  1.1  mlelstv #define  PWM_CTL_MODE1		__BIT(1)
     47  1.1  mlelstv #define  PWM_CTL_PWEN1		__BIT(0)
     48  1.1  mlelstv #define  PWM_CTL_WRITEZERO	(__BITS(16,31)|__BIT(14))
     49  1.1  mlelstv #define PWM_STA			0x04
     50  1.1  mlelstv #define  PWM_STA_STA4		__BIT(12)
     51  1.1  mlelstv #define  PWM_STA_STA3		__BIT(11)
     52  1.1  mlelstv #define  PWM_STA_STA2		__BIT(10)
     53  1.1  mlelstv #define  PWM_STA_STA1		__BIT(9)
     54  1.1  mlelstv #define  PWM_STA_BERR		__BIT(8)
     55  1.1  mlelstv #define  PWM_STA_GAPO4		__BIT(7)
     56  1.1  mlelstv #define  PWM_STA_GAPO3		__BIT(6)
     57  1.1  mlelstv #define  PWM_STA_GAPO2		__BIT(5)
     58  1.1  mlelstv #define  PWM_STA_GAPO1		__BIT(4)
     59  1.1  mlelstv #define  PWM_STA_RERR1		__BIT(3)
     60  1.1  mlelstv #define  PWM_STA_WERR1		__BIT(2)
     61  1.1  mlelstv #define  PWM_STA_EMPT1		__BIT(1)
     62  1.1  mlelstv #define  PWM_STA_FULL1		__BIT(0)
     63  1.1  mlelstv #define  PWM_STA_WRITEZERO	__BITS(13,31)
     64  1.1  mlelstv #define PWM_DMAC		0x08
     65  1.1  mlelstv #define  PWM_DMAC_ENAB		__BIT(31)
     66  1.1  mlelstv #define  PWM_DMAC_PANIC		__BITS(8,15)
     67  1.1  mlelstv #define  PWM_DMAC_DREQ		__BITS(0,7)
     68  1.1  mlelstv #define  PWM_DMAC_WRITEZERO	__BITS(16,30)
     69  1.1  mlelstv #define PWM_RNG1		0x10
     70  1.1  mlelstv #define PWM_DAT1		0x14
     71  1.1  mlelstv #define PWM_FIFO		0x18
     72  1.1  mlelstv #define PWM_RNG2		0x20
     73  1.1  mlelstv #define PWM_DAT2		0x24
     74  1.1  mlelstv 
     75  1.1  mlelstv struct bcm_pwm_channel;
     76  1.1  mlelstv 
     77  1.1  mlelstv struct bcm_pwm_channel *bcm_pwm_alloc(int num);
     78  1.1  mlelstv void bcm_pwm_free(struct bcm_pwm_channel *);
     79  1.1  mlelstv void bcm_pwm_control(struct bcm_pwm_channel *, uint32_t, uint32_t);
     80  1.1  mlelstv uint32_t bcm_pwm_status(struct bcm_pwm_channel *);
     81  1.1  mlelstv int bcm_pwm_write(struct bcm_pwm_channel *, uint32_t *, uint32_t *, int);
     82  1.1  mlelstv void bcm_pwm_set(struct bcm_pwm_channel *, uint32_t);
     83  1.1  mlelstv int bcm_pwm_flush(struct bcm_pwm_channel *);
     84  1.1  mlelstv void bcm_pwm_dma_enable(struct bcm_pwm_channel *, bool);
     85  1.1  mlelstv uint32_t bcm_pwm_dma_address(struct bcm_pwm_channel *);
     86  1.1  mlelstv 
     87  1.1  mlelstv #define PWM_CTL_MSEN		PWM_CTL_MSEN1
     88  1.1  mlelstv #define PWM_CTL_USEF		PWM_CTL_USEF1
     89  1.1  mlelstv #define PWM_CTL_RPTL		PWM_CTL_RPTL1
     90  1.1  mlelstv #define PWM_CTL_MODE		PWM_CTL_MODE1
     91  1.1  mlelstv #define PWM_CTL_PWEN		PWM_CTL_PWEN1
     92  1.1  mlelstv 
     93  1.1  mlelstv #define PWM_STA_STA 		PWM_STA_STA1
     94  1.1  mlelstv #define PWM_STA_GAPO		PWM_STA_GAPO1
     95  1.1  mlelstv #define PWM_STA_RERR		PWM_STA_RERR1
     96  1.1  mlelstv #define PWM_STA_WERR		PWM_STA_WERR1
     97  1.1  mlelstv #define PWM_STA_EMPT		PWM_STA_EMPT1
     98  1.1  mlelstv #define PWM_STA_FULL		PWM_STA_FULL1
     99  1.1  mlelstv 
    100  1.1  mlelstv 
    101  1.1  mlelstv #endif /* !BCM2835_PWMREG_H */
    102