|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" M" r' e# V- Z4 Z( s8 r#include <linux/init.h>
7 p/ w& ]; G0 k! _0 ? v#include <linux/module.h>7 U8 I8 ?5 |8 |
#include <linux/kernel.h>
" h- R1 ~6 [/ D4 u' H# S* l0 m#include <linux/types.h>
/ T# o8 C1 I1 @- K" }- C1 F1 ?3 n#include <linux/gpio.h>
1 e! B+ A( Z, Y' k9 g; ?5 }#include <linux/leds.h>
/ t r a+ N& ?: F! z1 U#include <linux/platform_device.h> t2 ^( ?% s3 m z3 y' ~+ z7 ` c
# ~& R& d3 K4 f
#include <asm/mach-types.h>7 d, a! J+ @- g8 ?8 n
#include <asm/mach/arch.h>
1 W4 p$ i3 A" q$ T: Q" X#include <mach/da8xx.h>5 T0 C7 @% Q" d1 h1 |
#include <mach/mux.h>0 v1 E0 G' I& E9 L5 \9 R
* f+ l& M$ T/ y2 _2 Z, U0 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 b) x* p# E% p# k#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 @9 U. I: O. |- t7 x: `$ X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 n4 i: P4 C9 M* O" |8 ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) y' S6 {; O t/ R7 s( Y9 k
4 s7 k: q% s& k' h, P/* assign the tl som board LED-GPIOs*/6 T# R/ K2 B% s# y) Q$ {
static const short da850_evm_tl_user_led_pins[] = {: O. ~. F% g2 P& o3 Y
/* These pins are definition at <mach/mux.h> file */
) ?) M* ^, h3 p) M: e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 \7 ]% z8 m3 E7 ^4 Q
-16 X3 D/ q! g1 }! t, w- I
};5 R% ~; Z# P9 M( }6 l6 I
; O2 a* _ j' E! j# j' j0 k7 K4 z. [static struct gpio_led da850_evm_tl_leds[] = {
7 m; |: G1 |2 X+ ]2 N {5 t8 ^) i: o, B3 S! }
.active_low = 0,
' W X' @) @" n, C' S .gpio = DA850_USER_LED0,4 c4 _. T! X' S- Y0 G" `
.name = "user_led0",( P: K( y' Z$ i: Y0 X
.default_trigger = "default-on",; r" K& r, |+ S- N+ P
},0 ?3 b9 w; a* q$ v+ Q5 A4 F+ d
{7 E; w J; w& A. a9 Q! A0 e; U5 J
.active_low = 0,
; q; Q1 p- d; l .gpio = DA850_USER_LED1,
3 [0 q4 @' |* ^0 p .name = "user_led1",, G! f" Z! n% f3 f% k
.default_trigger = "default-on",
6 X" c/ m# ~# W },1 e: k" R6 {* ~+ k! c) o& j' g
{
: B5 H+ }# A9 j9 G& \ .active_low = 0,- h$ G% ~" z6 a1 T
.gpio = DA850_USER_LED2,- F3 k7 V- v* }
.name = "user_led2",( P! E1 Z4 s" ?0 v6 _ ~. [
.default_trigger = "default-on",; W; @4 A& o8 w8 v3 \& R% j, K
},1 _( h: U# w7 k* n' x
{
. m0 W2 {+ w: F, f .active_low = 0,% x& |9 ?" S* S9 m/ F8 f$ p' w
.gpio = DA850_USER_LED3," i0 ?! H* W6 P! u
.name = "user_led3",8 l% h; f/ t2 X1 K5 }
.default_trigger = "default-on",' i8 N% V( f" s* N+ E7 @9 K6 |
},
9 T1 @' @$ D- D5 O};5 _) U+ d! N8 k6 o9 R2 ^
' w8 q0 T8 @/ N: M" Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. G$ ?0 `" @( r6 _7 q# t6 X! }0 i .leds = da850_evm_tl_leds,
3 G5 J1 A. L) H2 L6 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ `: x5 Z$ a& h0 y( W* R};' G* d$ N/ k/ L' s# J. ]! N: D
( j1 S: e8 f; B5 O8 N- C* ?static void led_dev_release(struct device *dev)* k. D A" N3 `% W5 t+ X3 e
{
( l: {: I- Q* {3 k3 S: j};
' E/ k k) E3 S5 x/ k7 X7 Q& l c& j& m2 F6 p5 }8 Z
static struct platform_device da850_evm_tl_leds_device = {8 \- o D4 S' d) Y/ c, C9 e6 O
.name = "leds-gpio",
, q9 s6 |7 X* U$ E3 N/ k .id = 1,' ~0 b7 {9 O2 ~, L; M- G6 |
.dev = {
9 t* Z4 @$ q8 N y5 J4 C .platform_data = &da850_evm_tl_leds_pdata,: y; C" f3 N6 j3 a4 i% m: u, U8 s
.release = led_dev_release,. }1 ^' T: B1 p! F7 x
}
$ j2 T9 D, C( l& C+ \2 f3 b};5 K3 y9 m, a9 h8 t; P& \
- p) M5 s2 M: q6 v
static int __init led_platform_init(void)
3 B) T3 z; |: l6 ~9 ]{
% Y" |9 ^0 p" [& A int ret;- k: O3 g5 Z# H- _; a0 _4 x
#if 0
( ?' Y, n$ @( c3 j$ J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 g7 T' T- O9 A' t) q$ W x
if (ret); d3 F) P+ A- q, T' W9 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% O( h) R7 P' C
"%d\n", ret);
+ T9 z+ { K" _6 B9 s4 ~#endif5 A3 `( ]3 ^; ~9 P9 S
ret = platform_device_register(&da850_evm_tl_leds_device);! t9 h! T: k6 O" s
if (ret)3 P4 l9 Q, e$ W( P0 X- A
pr_warning("Could not register som GPIO expander LEDS");2 C# M* ?; p& r$ I/ ?6 y% y2 o
else
5 o% b- d3 u% ~ printk(KERN_INFO "LED register sucessful!\n");2 }; N8 T& f/ j) g
5 x) T' V% o5 N* e, |* P
return ret;# m4 i* R' P3 Q" C7 j) B2 Q. ^6 L
}: w# C# ?/ z& t9 t# X" A6 X
+ _1 s! k1 r" {: w9 K) J
static void __exit led_platform_exit(void)- f* v& `. H& F# k! u( {0 o+ L9 B
{
. E* E% }1 Y' M1 G$ Z platform_device_unregister(&da850_evm_tl_leds_device);
G j8 I; m+ a
; d2 R: Q2 i t( `# I' B# f0 C printk(KERN_INFO "LED unregister!\n");
. ~, J% v/ C4 e4 u e}
* Z' R; t2 E% N# Z; _! q0 |6 H/ R3 Y% q* Y6 {
module_init(led_platform_init);
- P- V+ a/ F Dmodule_exit(led_platform_exit);
" R4 s( F1 N& O2 ^; |6 p- |- v( i; P# L1 ?, i
MODULE_DESCRIPTION("Led platform driver");
5 z# h& D, s% o% l- G0 _MODULE_AUTHOR("Tronlong");9 c: V h( d) _6 B4 F
MODULE_LICENSE("GPL");
7 L% I1 C" Q! t$ m Q# A
: s8 ~" B; G$ m: ~2 } |
|