|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 ~, e$ ~/ y! J6 o* G9 v#include <linux/init.h>
4 A+ |2 o: y. |9 O+ [$ `; G: ^#include <linux/module.h>, ]) z+ i6 \- j
#include <linux/kernel.h>0 x" B( Y; q4 h5 F4 w5 K1 u
#include <linux/types.h>
% r7 b, u4 Y8 n; W* T5 ^) X#include <linux/gpio.h>
1 p& D- O+ T# h#include <linux/leds.h>
0 O/ N& L3 W9 O' F#include <linux/platform_device.h>% ~3 h" s/ [ n* g7 L7 f
( x% l3 ~: w% s: j ~" F z
#include <asm/mach-types.h>) O2 F% ^: H2 h8 U4 s, T
#include <asm/mach/arch.h>9 O+ I5 D7 d2 R+ Q) c
#include <mach/da8xx.h>% C2 w( |" U$ | e7 a: z# L) Z$ d
#include <mach/mux.h>. E. `" {& `2 W# W) d4 j, r
: S6 x% G3 P/ C1 D' y9 i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 T9 h$ k2 Y# Q: k0 [3 R- t) j1 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) C2 d; }5 l' d2 \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ A! B& y$ a; ]$ S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 `& A$ i- S; F
9 `# I7 x) M8 R7 T7 G! f; N- ?/ D& w/* assign the tl som board LED-GPIOs*/" S9 R% x+ R( `
static const short da850_evm_tl_user_led_pins[] = {
k/ \; ^; R6 g3 j4 V# j( J, c /* These pins are definition at <mach/mux.h> file */
+ k/ W+ ^# m/ Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 |! u+ `( l2 H -14 K! P" m8 }" z1 x( x( Q* v6 k. r
};% q# k# }! A ^: P. U2 m8 M7 G
. C: L4 a% d' j; Q, H2 tstatic struct gpio_led da850_evm_tl_leds[] = {, j4 Y" [, ^; r7 g; Z( j
{" ?$ C0 L# a) D$ C' l
.active_low = 0,
2 H# w0 d3 O. d .gpio = DA850_USER_LED0,. {0 ^" X5 a+ _5 U
.name = "user_led0",% S o+ @2 p; C7 @9 T
.default_trigger = "default-on",# V3 I3 V5 i7 h4 ~7 y! J
},! c3 [3 ^- D# S. [4 P7 N
{9 Z. m) O4 H/ ^8 N
.active_low = 0,
. F y, I- ~" {; Q .gpio = DA850_USER_LED1,- y+ h h0 S% X. c9 z' A; z9 H
.name = "user_led1",; | t+ K$ ~! h) N
.default_trigger = "default-on",
- }+ M0 W) o2 |6 |' n },
! x. _6 f: c: l2 h( ^- @! B {
- @% h' e" |- Z2 K; ~ .active_low = 0,( ~4 y! e# K1 I4 L- h1 e3 l# [
.gpio = DA850_USER_LED2,
0 ?8 e; A4 {& T .name = "user_led2", |7 ~" v C" y. o
.default_trigger = "default-on",- o& d5 p. l, S1 E$ V7 e e: C
},/ r! V- C) ^* `& p' J# U
{. u' x7 s6 e" O0 p' i
.active_low = 0,9 v( l# u5 i1 g0 d: S0 X
.gpio = DA850_USER_LED3,. x; U( l- Z% q5 R# e: K4 w6 _7 _
.name = "user_led3",
# W% h0 {$ K8 h, u6 l% Y .default_trigger = "default-on",: c/ o& i: e% o+ P7 H+ Y1 }& ~" s
},
* S. B2 C+ q$ i1 x0 s3 g, l2 p};
* S/ S9 p% y, [8 S7 K$ D& W0 _+ D/ U6 I$ g& ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, @1 R( L5 y- c# W) i
.leds = da850_evm_tl_leds,
- _# ~5 ~6 X; Z* l8 |. J/ ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 P$ J* h1 S, L b$ e' P9 ]
};
$ i2 R* i& b# J% o
8 T" U% Q; d# m7 s: ostatic void led_dev_release(struct device *dev)
. d2 @" b0 Y% w{
P$ a5 M/ |. E9 C9 T};
/ o; @) G+ v U) ~% E
5 N& K7 Z# ` t0 Estatic struct platform_device da850_evm_tl_leds_device = {
& A1 k' p7 ]+ ~# N, ]( v7 a+ E .name = "leds-gpio",/ ^9 ~! V4 W" k( q7 M+ _/ C6 O
.id = 1,
9 B" e k. T6 S% b6 a$ E& O .dev = {
6 r+ D+ b; [, V( m4 j- W7 T .platform_data = &da850_evm_tl_leds_pdata,
: S& |% b: T- x# ]3 {) C8 k" ? .release = led_dev_release,
5 P5 x0 g) b' e9 ?9 {# U4 p; Y- j( c6 e }
! g% i/ p5 P% [; p. ?+ T6 Q};
: d% e" D2 l2 N6 D/ T- z3 b! L( V! R5 j* u1 g3 \
static int __init led_platform_init(void)7 K' e" @4 G/ y4 D
{
7 L: ^8 X+ ?) u, c* a int ret;
: F/ ~4 y" t' u4 }4 {3 r7 A#if 0
) F' m# E) }1 ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* \$ C# C. ?( Q1 Z8 j
if (ret)7 [& ^# X8 F: @4 _+ u, D' h! J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 Q# o; q: A8 ?. V
"%d\n", ret);
6 _4 \0 |( _4 ]' q7 Z6 l1 N#endif
+ X4 L N8 P# K% V/ d ret = platform_device_register(&da850_evm_tl_leds_device);% L7 B2 c N$ l, M, A7 ^
if (ret)
) G- W1 A1 I$ I% @ pr_warning("Could not register som GPIO expander LEDS");4 s2 w! T# o* i8 T- W/ |
else
* N, ~. _5 f1 J* r" R2 \, }5 l( Q printk(KERN_INFO "LED register sucessful!\n");2 O& P+ |1 L, U5 |
* ?2 H' I1 _5 u return ret;
$ h6 A) k6 G1 `: ]+ s) |$ X6 W}
+ y/ E& [- f) q: N" F: x" w( R y0 W
static void __exit led_platform_exit(void)' a6 L7 U ]# a" s: Z
{
! L, F0 G3 O: {/ B9 C8 j platform_device_unregister(&da850_evm_tl_leds_device);
V0 \/ Q9 T4 I3 d! }; ^) Y, A, V- Z, d4 j! H+ U+ M! `
printk(KERN_INFO "LED unregister!\n");
+ F: P4 ?$ c1 Y: m}( v5 f, }1 Z' P( J4 q# D. I/ Q
w% ?8 m7 n6 K
module_init(led_platform_init);4 [9 S8 X, w" c( l, z, A
module_exit(led_platform_exit);/ I0 r: i4 S) `0 h/ j
: N% h+ E: s7 T# k2 aMODULE_DESCRIPTION("Led platform driver");
8 C6 m3 ^$ R2 K( A' @MODULE_AUTHOR("Tronlong");
' X% p7 `8 G# r+ t T0 n8 w' VMODULE_LICENSE("GPL");
" S" a3 j" {# t+ t4 b* |! V( n( r" A0 ]
|
|