Interfacing

Can4linux drivers use for banana pro

8 903
Edited by vaibhavkambli at Nov 08, 2016 06:55

I want to use Can4linux drivers for Banana pro, but there is no Banana Pro specific board handling configuration file(Can4linux), even though both pi and pro are using same allwinner a20 chip I am not sure that whether I can directly use banana pi board handling files for pro.


What all changes do I need to make in bananapi.c and bananapi.h files in can4linux drivers  so that they get compatible with Banana Pro?Please help me with Can4linux for banana pro.




please find code below.
can4linux/bananapi.c//board handling and configuration
/* banana pi board handling
*
*/

/* use it for pr_info() and consorts */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt

#include "defs.h"
#include <linux/pci.h>

     #include <linux/delay.h>

#include <linux/clk.h>                        /* clk_get */
#include <mach/clock.h>
#include <mach/gpio.h>

/* already defined in arch/arm/plat-sunxi/include/plat/platform.h */
// #define PIO_BASE 0x01c20800    /* SW_PA_PORTC_IO_BASE */

#define PI_CFG0_OFFSET 0x120
#define PI_CFG1_OFFSET 0x124
#define PI_CFG2_OFFSET 0x128
#define PI_CFG3_OFFSET 0x12c
#define PI_DATA_OFFSET 0x130


#define PH_CFG2_OFFSET 0x104

int can_requestirq(int minor, int irq, irqreturn_t (*handler)(int, void *))
{
int err;

        DBGIN();
        /*

        int request_irq(unsigned int irq,                        // interrupt number
        void (*handler)(int, void *, struct pt_regs *), // pointer to ISR
              irq, dev_id, registers on stack
        unsigned long irqflags, const char *devname,
        void *dev_id);

        dev_id - The device ID of this handler (see below).
        This parameter is usually set to NULL,
        but should be non-null if you wish to do  IRQ  sharing.
        This  doesn't  matter when hooking the
        interrupt, but is required so  that,  when  free_irq()  is
        called,  the  correct driver is unhooked.  Since this is a
        void *, it can point to anything (such  as  a  device-spe-
        cific  structure,  or even empty space), but make sure you
        pass the same pointer to free_irq().

        */

        err = request_irq(irq, handler, IRQF_SHARED, "can4linux", &can_minors[minor]);


        if (!err) {
                DBGPRINT(DBG_BRANCH, ("Requested IRQ: %d @ 0x%lx",
                        irq, (unsigned long)handler));
                irq_requested[minor] = 1;
        }
        DBGOUT();
        return err;
}


int can_freeirq(int minor, int irq)
{
        DBGIN();
        irq_requested[minor] = 0;
        // pr_info(" Free IRQ %d  minor %d\n", irq, minor);
        free_irq(irq, &can_minors[minor]);
        DBGOUT();
        return 0;
}

/*
* Perform Vendor-Init, that means sometimes CAN controller
* or only board manufacturer specific initialization.
*
* Mainly it gets needed IO and IRQ resources and initializes
* special hardware functions.
*
*/

int can_vendor_init(int minor)
{
        DBGIN();
        can_range[minor] = CAN_RANGE;
        DBGPRINT(DBG_DATA, ("Assume Address of CAN%d at %lx, range 0x%x\n",
                minor,  proc_base[minor], CAN_RANGE));

        /* Request the controllers address space */
        if (NULL == request_mem_region(
                    proc_base[minor], can_range[minor] , "CAN")) {
                DBGPRINT(DBG_DATA,
                        ("Request_mem_region CAN-IO failed at %lx\n",
                proc_base[minor]));
                DBGOUT();
                return -EBUSY;
        }

        // pr_info("Second call to ioremap() for phy addr %lx\n", proc_base[minor]);
        can_iobase[minor] = ioremap(proc_base[minor], can_range[minor]);
        // pr_info(" 0x%08lx remapped to 0x%08lx\n",
        //    proc_base[minor], (long unsigned int)can_iobase[minor]);


        /* pr_info("MAX_IRQNUMBER %d, use IRQ %d\n", MAX_IRQNUMBER, IRQ[minor]); */

        if (IRQ[minor] > 0 && IRQ[minor] < MAX_IRQNUMBER) {
                if (can_requestirq(minor, IRQ[minor], can_interrupt)) {
                        pr_err("Can[%d]: Can't request IRQ %d\n",
                                        minor, IRQ[minor]);
                        DBGOUT();
                        return -EBUSY;
                }
        } else {
                /* Invalid IRQ number in /proc/.../IRQ */
                DBGOUT();
                return -EINVAL;
        }
        DBGOUT();
        return 0;
}


/* Called from __init,  once when driver is loaded
   set up physical addresses, irq number
   and initialize clock source for the CAN module

   Take care it will be called only once
   because it is called for every CAN channel out of MAX_CHANNELS
*/
int init_board_hw(int n)
{
static int already_called;
int ret;
int minor = -1;
void __iomem *gpio_base = ioremap(PIO_BASE, 0x400);
void __iomem * port_h_config = gpio_base + PH_CFG2_OFFSET;

uint32_t tmp;

        DBGIN();
        ret = 0;
        
        /* only one CAN Channel, no need for index n */
        proc_base[0] = CAN0_BASE_ADDR;
        IRQ[0] = CAN0_INT0;


        


        /* ioremap gpio config adresses
http://forum.lemaker.org/viewthr ... e=1&extra=#pid12212
         * */

/*

volatile unsigned long GPIO_BASE;
volatile unsigned long *PI_CFG;
volatile unsigned long *PI_DATA;



GPIO_BASE=(unsigned long)ioremap(PIO_BASE,0x400);
PI_CFG = (unsigned long *)(GPIO_BASE + PI_CFG2_OFFSET);
PI_DATA= (unsigned long *)(GPIO_BASE + PI_DATA_OFFSET);
writel(0x00000000,PI_CFG);//set port i as input

*/


/* PH20 select                        Connector3 Pin
*  bit 18:16  100 CAN_TX        16
*  bit 19 -
* PH21 select
*  bit 22:20  100 CAN_RX        18
*  */

        msleep(100);
        // pr_info("gpio base %p, %p\n", gpio_base, port_h_config);
        msleep(100);
        tmp = readl(port_h_config);
        // pr_info(" PIOH 0x%08x\n", tmp); /* PIOH 0x10110000 */
        msleep(100);
        tmp &= 0xFF00FFFF;
        writel(tmp | (4 << 16) | (4 << 20), port_h_config);
        msleep(100);
        // pr_info(" PIOH 0x%08x\n", readl(port_h_config));
        msleep(100);

        /* enable clock
         * Manual 1.5.4.21  APB1 Module Clock Gating offset 0x6c
         * Bit 4 CAN_ABP_GATING
         *
         * from 24 Mhz Quartz?
         * two dividers CLK_RAT_N    /1, /2, /4, /8
         *              CLK_RAT_M    1/1...32
         */

        /* FIXME ioremap adress */
        writel(readl(0xF1C20000 + 0x6C) | (1 << 4), 0xF1C20000 + 0x6C);

        if (!already_called && virtual == 0) {
                /* make some sysctl entries read only
                 * IRQ number
                 * Base address
                 * and access mode
                 * are fixed and provided by the PCI BIOS
                 */
                can_sysctl_table[CAN_SYSCTL_IRQ - 1].mode = 0444;
                can_sysctl_table[CAN_SYSCTL_BASE - 1].mode = 0444;
/*
arch/arm/mach-sun7i/include/mach/clock.h
139:#define CLK_MOD_CAN             "can"
*/
                proc_clock = clk_get_rate(clk_get(NULL, CLK_MOD_CAN));
                already_called = 1;
        }
        DBGOUT();
        return ret;
}

void exit_board_hw(void)
{
}

/**
This function clears hardware interrupt requests from the device after
the interrupt has been serviced.

*/

void board_clear_interrupts(int minor)
{
        DBGIN();
        ;
        DBGOUT();
}




can4linux/bananapi.h//board handling and configuration

/************************************************************************/
/* hardware access functions or macros */
/************************************************************************/




#ifdef IODEBUG
#define CAN_OUTL(bd, adr, v)        \
        (pr_info("Cout: (%x)=%x\n", (u32)&((canregs_t *)can_iobase[bd])->adr, v),\
                (writel(v, (u32) &((canregs_t *)can_iobase[bd])->adr)))
#else


   /* Memory long word access */
#define CAN_OUTL(bd, adr, v)        \
                (writel(v, (u32) &((canregs_t *)can_iobase[bd])->adr))
#endif /* IODEBUG */


#define CAN_SETL(bd, adr, m)        \
        writel((readl((u32) &((canregs_t *)can_iobase[bd])->adr)) \
                | (m), (u32) &((canregs_t *)can_iobase[bd])->adr)
#define CAN_RESETL(bd, adr, m)        \
        writel((readl((u32) &((canregs_t *)can_iobase[bd])->adr)) \
                & ~(m), (u32) &((canregs_t *)can_iobase[bd])->adr)
#define CAN_INL(bd, adr)                \
                (readl((u32) &((canregs_t *)can_iobase[bd])->adr))
#define CAN_TESTL(bd, adr, m)        \
        (readl((u32) &((canregs_t *)can_iobase[bd])->adr) & (m))






can4linux_banana_pro_board_handling.zip

3.33 KB, Downloads: 1

abc20180506
jordan retro 11
ralph lauren
moncler jackets
ralph lauren outlet
christian louboutin outlet
longchamp handbags
moncler outlet
oakley sunglasses
michael kors outlet
michael kors outlet canada
skechers shoes
oakley sunglasses
timberland boots outlet
fitflops sale
gucci handbags
adidas shoes
ray ban sunglasses
coach factory outlet online
air max 2019
tory burch outlet
valentino shoes outlet
michael kors factory outlet
canada goose outlet
air max 97
cheap ray ban sunglasses
michael kors outlet
yeezy 350 boost
canada goose outlet
michael kors outlet
pandora charms
burberry outlet
air max 90
michael kors outlet
tiffany and co
nike shoes for men
cheap uggs
coach outlet store
valentino shoes
canada goose uk
polo ralph lauren
birkenstock sandals
asics shoes
abercrombie and fitch
pandora outlet
canada goose
jordans
ralph lauren
mont blanc
michael kors
michael kors handbags
moncler jackets
michael kors outlet
hermes birkin
red bottoms
adidas nmd
uggs outlet
kate spade outlet store
adidas yeezy
abercrombie
philipp plein shirt
ugg outlet
ralph lauren outlet online
cheap jordans
kate spade
cheap jordans
coach outlet canada
canada goose sale
birkenstock outlet
moncler outlet
adidas nmd
oakley sunglasses
jordans
jordan shoes
cheap jordans
ugg boots on sale
pandora jewelry
gucci outlet
kate spade outlet
ferragamo outlet
ralph lauren uk
oakley sunglasses
ugg outlet
fitflops
kate spade handbags
adidas nmd
canada goose outlet
jordan shoes
yeezy boost
oakley sunglasses
coach outlet online
canada goose
birkenstock sandals
adidas shoes
kate spade outlet store
oakley sunglasses
ray ban sunglasses
pandora jewelry
kobe shoes
discount oakley sunglasses
polo ralph lauren outlet online
canada goose outlet
adidas outlet
coach outlet
moncler
ray ban sunglasses discount
michael kors outlet clearance
michael kors outlet clearance
michael kors outlet clearance
adidas outlet
salvatore ferragamo
nike shoes
michael kors outlet clearance
coach factory outlet
ralph lauren
coach factory outlet
cheap jordans
ultra boost
canada goose outlet
moncler jackets
coach outlet
canada goose jackets
salvatore ferragamo shoes
uggs
gucci handbags outlet
louis vuitton outlet online
longchamp outlet
pandora outlet
fitflops
new balance outlet
tory burch outlet
abc20180506

20186.14chenjinbei
flops
cheap jordan shoes
air max 270
kate spade
mont blanc
fitflops
jordans
mishka clothing
jimmy choo shoes
camisetas de futbol replicas
timberland boots
adidas football boots
coach outlet online
supra shoes
malone souliers mules
fussball trikots
supreme
ralph lauren
ferragamo shoes
burberry canada
christian louboutin
asics running shoes
nfl jerseys wholesale
air max 97
red bottoms
fitflop sandals
ralph lauren
puma slides
manchester united jersey
air max 90
true religion jeans
camisetas de futbol baratas
beats by dre
coach outlet online
nike epic react
y-3 shoes
links of london
ralph lauren
nike air max
kate spade handbags
oakley sunglasses
jordan 3
cheap jerseys
nike flip-flops
air jordan 14
light up shoes
nike dunks
new balance
converse shoes
cheap nfl jerseys
adidas yeezy 350
nike blazer
ray ban sunglasses
nike lunarglide
air max
ferragamo outlet
air jordan 11
nike shox
michael kors handbags
adidas jeremy scott
jordans
coach factory outlet
ralph lauren uk
ray ban outlet
jordan 4
air max 95
balance shoes
coach handbags
ralph lauren
miu miu shoes
air max
coach outlet store
michael kors outlet
breitling watches
nike air force
ralph lauren
carnival shoes
vans shoes
adidas slides
christian louboutin shoes
nike tn
balenciaga shoes
kobe 12
running shoes
burberry outlet
air max 2017
air max 1
harden vol 1
air force 1
roshe run
cheap mlb jerseys
adidas nmd
juicy couture outlet
superdry clothing
ferragamo
nike shoes
wholesale nfl jerseys
huarache
michael kors outlet clearance
jordan
cartier jewelry
christian louboutin outlet
air max plus
mac cosmetics
prada handbags
coach outlet store online
cheap nfl jerseys
under armour outlet
dior handbags
belstaff jackets
marc jacobs
pandora charms
michael kors
michael kors outlet online
nike blazer
polo ralph
jordan 5
hermes outlet
coach factory outlet
celine outlet
coach outlet
hermes birkin bag
converse shoes
mulberry handbags
jordan xx9
nike sb
off-white clothing
cheap soccer jerseys
swarovski
tory burch outlet
longchamp
converse uk
nike revolution
nike uk
maillot de foot pas cher
flip-flops
polo outlet
nike shoes for men
ralph lauren
polo outlet
michael kors taschen
tag heuer watches
michael kors outlet store
soccer shirts
air max 2018
air jordan
adidas outlet store
basketball shoes
montblanc fountain pens
barcelona jersey
jordan 8
coach
michael kors handbags
ray ban sunglasses
pandora jewelry canada
coach factory outlet
true religion jeans
prada bags
timberland boots
supreme outlet
baseball jersey
bvlgari rings
adidas stan smith
kate spade outlet online
suicoke sandals
cheap ray bans
oakley sunglasses
mont blanc pens
kate spade
oakley sunglasses
fitflops outlet
cheap nhl jerseys
adidas shoes
adidas flip flops
off-white clothing
coach handbags
coach factory outlet online
kobe 11
nike cortez
nike outlet store
coach factory outlet online
hermes kelly bag
mbt shoes
jordan 6
cheap soccer jerseys
beats by dre
cheap nfl jerseys
longchamp outlet
pandora outlet
vibram five fingers
hermes
air max
nike kyrie 3
supreme uk
adidas yeezy
jordan
nike free run
louboutin
lebron 15
pandora jewelry
coach outlet online
polo ralph lauren
adidas superstar
maglie calcio
snapbacks wholesale
red bottom shoes
prada handbags
hollister outlet
true religion jeans
soccer jersey
cheap mlb jerseys
longchamp outlet
valentino shoes
manolo blahnik shoes
pandora charms
nike roshe
nike factory outlet
balenciaga shoes
ralph lauren uk
giuseppe zanotti shoes
air max
timberland boots
air jordan
burberry outlet online
michael kors handbags
michael kors handbags
jordan pas cher
nike outlet online
alexander mcqueen shoes
nfl jerseys
tory burch bags
scarpe mbt
oakley vault
van cleef & arpels jewelry
air huarache
coach outlet online
yeezy 500 blush
vans shoes
christian louboutin
longchamp handbags
cheap nba jerseys
harden vol 2
bcbg
mlb jerseys
asics
"nfl jerseys
"
yeezy shoes
stuart weitzman shoes
michael kors uk
timberland outlet
ralph lauren outlet
jordan shoes
longchamp
nike free run
hermes uk
ralph lauren outlet
michael kors canada
new balance sandals
michael kors outlet
givenchy handbags
adidas outlet
ralph lauren
jordan 12
undefeated shoes
nike presto
fingerlings monkey
jordan 1
oakley sunglasses
nhl jerseys
air jordan
flip-flops
breguet watches
pandora uk
wedding shoes
fila sneakers
oakley sunglasses
oakley sunglasses wholesale
true religion jeans
nike mercurial vapor
michael kors outlet store
prada outlet online
[bcheap nfl jerseys
ray ban
coach outlet
burberry outlet store
adidas stan smith
michael kors outlet
jordan shoes
dansko shoes
mcm bags
birkenstock
ray ban sunglasses
maglie calcio a poco prezzo
cheap replica watches
ray ban sunglasses
polo outlet
tory burch outlet
pandora jewelry canada
ray ban
stussy hoodie
oakley canada
baseball bats
adidas wings
true religion jeans
columbia sportswear
michael kors outlet
nfl jerseys
prada
ray ban sunglasses cheap
nike shoes
true religion
coach outlet
kate spade
longchamp handbags
pandora jewelry
nike free
kate spade outlet
fitflop sandals
fitflops sale clearance
nike outlet
nike free
kevin durant shoes
jordans
adidas nmd
louboutin
longchamp
adidas uk
birkenstock sandals
gucci slides
coach factory outlet
mizuno running shoes
michael kors handbags
ralph lauren
ralph lauren uk
adidas ultra boost
ralph lauren polo shirts
louboutin
rolex watches
louboutin outlet
michael kors outlet
puma fenty sandals
louboutin
coach outlet online
audemars piguet
tory burch uk
nike uk
bottega veneta
nike outlet
air jordan
michael kors outlet
tod's shoes
nike outlet store online
dolce and gabbana
herve leger dresses
christian louboutin outlet
cheap oakley sunglasses
Fußballtrikots günstig
birkenstock outlet online
jordan shoes
adidas outlet store
maillot de foot
coach outlet online
cheap ray ban sunglasses
coach outlet online
timberland outlet
coach
coach outlet
coach factory online
kate spade
curry shoes
air jordan
supreme paris
swarovski jewelry
tory burch
jordan retro
nike tennis
nike outlet
ray ban
balenciaga sandals
20186.14chenjinbei

20188.15wengdongdong
nike tennis
air max 1
bottega veneta
Fußballtrikots günstig
russell wilson jersey
air max
jordan 8
tory burch outlet
nike mercurial superfly
levi's jeans
mulberry handbags
pasotti ombrelli
tory burch bags
coach handbags
timberland boots
michael kors uk
vetements clothing
north face outlet
lebron 14
beats by dre
victoria's secret outlet
dior handbags
vans outlet
supreme clothing
lululemon
coach outlet online
salvatore ferragamo shoes
nike cortez
true religion jeans
soccer jerseys
oakley sunglasses
adidas slides
tiffany jewelry
birkenstock sandals
nike dunks
tory burch sandals
michael kors handbags
off-white
persol sunglasses
rolex watches
montblanc
ralph lauren jeans
new balance shoes
ray ban sunglasses
hermes belt
nike dunks
adidas football boots
nike tn
louboutin
cheap soccer jerseys
manchester united jersey
swarovski crystal
fitflop
coach outlet
polo outlet
michael kors handbags
burberry canada
ray ban sunglasses
christian louboutin
nike uk
juicy couture
jordan 12
fila shoes
wholesale nfl jerseys
supra shoes
lululemon sale
birkenstock sandals
bvlgari rings
air max
air max
oakley sunglasses
longchamp handbags
oakley sunglasses cheap
adidas outlet
ray ban
supra shoes
basketball shoes
new balance
air max plus
birkenstock outlet
omega watches
nike outlet
vans shoes
pandora charms
michael kors handbags
birkenstock sandals
jordan 1
nike shox
barcelona jersey
shoe carnival
scarpe mbt
ralph lauren
woolrich jackets
longchamp handbags
adidas yeezy
hermes outlet
air max 97
20188.15wengdongdong

You have to log in before you can reply Login | Sign Up

Points Rules