标题: McBSP时钟、同步、数据线不正常 [打印本页] 作者: gaocaimary 时间: 2014-10-16 10:58 标题: McBSP时钟、同步、数据线不正常 我讲创龙在DSP中使用的例子移植到ARM中,如下是我的底层驱动程序: . r: P- ~5 r' b& c/*7 h \" X( W9 H) R" [7 k
* Copyright (C) 2009 Texas Instruments Inc! L. Y1 s6 p, ]; C
* 6 E7 A# T0 L/ G' e9 v. A) ? * This program is free software; you can redistribute it and/or modify, n/ E" a7 l* S' M) p( x
* it under the terms of the GNU General Public License as published by 2 V. o; s9 o" s8 y& y' o * the Free Software Foundation; either version 2 of the License, or 8 Z. k: H. c6 j) {, K * (at your option)any later version.$ f* o/ J5 ~3 [* l6 k
* 8 H& q5 H9 F2 u( C5 [8 a, X3 k4 y * This program is distributed in the hope that it will be useful,( i; u; Q( R! I8 a. ]/ u
* but WITHOUT ANY WARRANTY; without even the implied warranty of $ ?+ ~. c' P$ m4 n. N7 T4 L * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6 }8 R& H) T3 B0 N' Z * GNU General Public License for more details." W1 A, s. w' I/ V7 U0 _, k
* / e3 U6 z( Z& M) a * You should have received a copy of the GNU General Public License ! y" ^5 h. U, ~. Y( v, T * along with this program; if not, write to the Free Software + {0 l% b. L: F' x * Foundati " ]$ _+ Z1 K8 s' v/ |0 ?% e: v*/- H2 |9 ^- W0 @+ h4 B) c4 z
#include <linux/module.h> - k" ?6 Q# y! f% e! O#include <linux/init.h>/ M9 W9 K9 _) ?) N1 I5 O
#include <linux/errno.h> 9 p* G6 U0 ~% {2 p- |8 B#include <linux/types.h>4 I2 R9 \$ |, V# y; r
#include <linux/interrupt.h>; s4 e* @% q0 H9 d, V
#include <linux/io.h>+ v' E& Z# ]$ k; @) H
#include <linux/sysctl.h> 1 E2 f' \/ n5 U' T) o0 p#include <linux/mm.h>* {6 c. D& h m* i; t5 }
#include <linux/delay.h>8 E9 D% c3 H: P7 S: P
#include<linux/kernel.h>) ^$ s. q4 p5 V
#include<linux/fs.h> 8 b! L! v0 B$ v& Q. G0 i' }( D9 [#include<linux/ioctl.h>$ M! ~& Y9 d6 e+ F
#include<linux/cdev.h>7 B# Y5 [; k6 |) u- ^+ G
#include<linux/kdev_t.h> O# j r3 V; Z4 ^#include<linux/gpio.h>: @# E/ W' h+ I* ]3 e2 m
#include <mach/hardware.h> - n3 q% ~- L) L$ T+ {( H#include <mach/irqs.h>1 E% |- p+ Z. J% T" k. I6 r
: W0 B. X/ `* M* E- L; T" S#include <asm/mach-types.h> " s/ @. ]3 U7 b#include <asm/mach/arch.h>/ V" }. s! B0 }, X* D
#include <mach/da8xx.h> 2 x) `2 `% `/ Z' f$ x/ o#define SYSCFG_BASE 0x01c14000# [. ], F3 _5 k/ U
#define PINMUX1_OFFSET 0x124 % I; R |% @& { H8 n7 Z6 N* D
#define PINMUX18_OFFSET 0x168 3 S# M/ ]7 e; S5 b' L, K#define PINMUX19_OFFSET 0x16c - i, b3 r; b: A#define SPCR_ADDR 0x01D11008 //MCBSP1_SPCR# K ~ B" X2 a6 }9 y. }: j2 J2 A
#define RCR_ADDR 0x01D1100C //MCBSP1_RCR% d. R. x& |) q3 C9 C: ]5 P7 [
#define XCR_ADDR 0x01D11010 //MCBSP1_XCR 5 R6 x0 C. v' v$ P( ]#define SRGR_ADDR 0x01D11014 //MCBSP1_SRGR & h3 Q) M" a) F; Y# N3 a#define PCR_ADDR 0x01D11024 //MCBSP1_PCR " H. k% H6 w$ l. N( M - v) i, P; I% o2 O* o4 S: T& {#define DXR_ADDR 0x01D11004 //MCBSP1_DXR8 ~6 V$ s- _2 ~$ H: ]1 g& C" I
#define DRR_ADDR 0x01D11000 //MCBSP1_DRR S( r6 d! G/ ?3 t4 c
//PSC3 n8 m/ `" m2 i: P: W
#define PTCMD_ADDR 0x01E27120 8 G+ H+ N0 ~7 d9 R G$ J#define MDCTL15_ADDR 0x01E27A3C3 k/ u4 C- P$ G# _* g
#define PDCTL1_ADDR 0x01E273043 L) o, _9 Q6 J: y; \" r
//GPIO8 direction # `3 F o& j- V6 Z# q#define GPIO8_DIRECT 0x01E260B0 ) n, R/ [' o' V; L4 H8 L$ m# B- u' Z#define GPIO8_OUT 0x01E260B4 ' {3 o' K' q' R% d$ |+ h#define GPIO8_IN 0x01E260C03 }4 { f6 S; N
; {6 G: p& K: g) _//#define MCBSP1_RINT 99 : `) h; X& Z4 Z' Y+ |
//#define MCBSP1_XINT 100 ! s: M; R" Q1 b6 t9 [' `' w
static int MCBSP_MAJOR=239;: J0 V2 r s* l- N! V$ |+ E' ]
static int MCBSP_MINOR=0;. {) o) g2 m( Z0 p
static int count =1;: U- l2 [) d2 h5 B9 P
* ?: H+ I7 q! O3 K+ h* h
#define MCBSP_NAME "MCBSP-device" ) S0 n' p* F) P. F) g 3 U- m; w0 K5 r/ E5 K* G1 hstatic struct cdev *mcbsp_cdev;" {" v( U3 j" C4 y5 N) a
static struct class *mcbsp_class;) d9 p$ x/ E" D# L1 k
static dev_t mcbsp_dev;4 H1 y9 G6 H/ ^4 h
unsigned int DRR_data;& T, _$ V. K) [" G7 f, d. o; c
unsigned int DXR_data; ) j. e5 W- I3 c2 O W" Hstatic int mcbsp_open(struct inode *inode,struct file *file) W5 e! A% @! D! n; m7 o' o
{' o: y0 ]9 ]& M/ G, x7 N, C7 n; W9 I
8 K; n' l4 @6 w { //interrupt enable,initialized 5 o% [; E! w$ R; n3 ]8 ~ A V unsigned int temp; 0 c% ]9 A+ j0 \ //SLEEP_EN(GPIO8[10])---0 / V7 E$ h1 ^: u& s4 h temp = __raw_readl(IO_ADDRESS(GPIO8_OUT));/ l7 M7 l& | _7 Y
temp=temp&(~0x00000400);- _, k8 H& ~* z8 a; G5 E* ]
__raw_writel(temp,IO_ADDRESS(GPIO8_OUT));//GPIO8[10] 7 D1 m( A) B j! |0 U5 @( C3 s //RESETn(GPIO8[8])----0----1 . B. i1 F6 a+ G( P' u temp = __raw_readl(IO_ADDRESS(GPIO8_OUT));% ]6 ]% I2 J. v" t
temp=temp&(~0x00000100); + Y6 k' {) n2 m' p2 W% B# M8 Q7 K __raw_writel(temp,IO_ADDRESS(GPIO8_OUT));//GPIO8[8]---0. F: }1 X/ y. Z8 n. @& V
udelay(100);2 q7 d, v# ]6 U
temp=temp| 0x00000100; ; _! J$ L3 q# `: S* q __raw_writel(temp,IO_ADDRESS(GPIO8_OUT));//GPIO8[8]---18 ?8 W7 l8 ~2 G$ r
udelay(100); a4 @- u- L0 w8 y1 s) z3 M printk("open success!\n"); ; r" |5 V% W- H b. p+ f& J return 0;, u @) h& [2 L6 D* ~( g
} " e8 T8 N$ w% _ | ! h/ Q( ^- X( @! pstatic int mcbsp_release(struct inode *inode,struct file *file)" z x6 t8 p; g7 o! x# g: i
{ ! W# i" r2 m7 }+ V4 Z. ]2 k printk("release success!\n"); 7 x9 p. y6 t. l6 U; e7 ] return 0;% x* Y' Q( g, M' |9 r
}1 w5 r7 Q x {% A3 F; A
3 r) Q3 @# l: m! s" h0 Cstatic ssize_t mcbsp_write(struct file *filp,const char *buf,size_t len,loff_t *off)- _( ]1 n. C( W; X4 n. P' v
{ t5 W0 J# i& o$ | copy_from_user(&DXR_data,buf,len); 3 R7 g1 }# y t6 D. ~ iowrite32(DXR_data,IO_ADDRESS(DXR_ADDR)); 4 D7 o: D/ r" p' ?: V2 [/ C% Z% S6 z( e return 0;! w3 L2 n. t6 T8 F$ G+ g: V5 q$ r