|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% d& E6 o- t! c. j% G. k
#include <linux/init.h># c; s/ k1 a J8 l) D" N
#include <linux/module.h>
0 s1 o/ m* G: z6 L$ V4 ~#include <linux/kernel.h>
+ E9 C$ Z& v* C: v9 {#include <linux/types.h>; S1 N8 ]1 x4 j; k. J+ }/ g
#include <linux/gpio.h>
$ n6 B2 W6 @% g. r; F#include <linux/leds.h>2 ]- a) I- N( I) p2 }8 S" B
#include <linux/platform_device.h>1 w, C0 Z5 w$ C3 i. U
% |- e w" N% r" b2 h
#include <asm/mach-types.h> K8 @2 t: A, F, t+ G' a
#include <asm/mach/arch.h>5 g1 H2 U9 S0 N
#include <mach/da8xx.h>8 Y% F' s* Q. N- z3 `
#include <mach/mux.h>& C/ L2 O, I" l0 K& O' g
2 N; H- W# f: ?2 W! y8 G1 M6 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" i- z" A/ E1 r& n( B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 w" ~, b4 t/ S" n( v* K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& g# [% _ x% B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): _: X" p- G$ c8 u7 g
D. ~& ?; r0 `7 O6 j& N/* assign the tl som board LED-GPIOs*/
: T# t- \1 N$ ^1 C7 bstatic const short da850_evm_tl_user_led_pins[] = {
$ O, g! @! O2 a- G. Q; r' f /* These pins are definition at <mach/mux.h> file */; L- z+ i8 l1 \- E6 _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
N1 n7 ^" A& |6 T4 ^/ g' n -1
2 e2 g$ r! G/ _+ }( E) Y};- S( @+ |. q1 |$ R, Q
+ m4 G1 m" t4 J! k; f
static struct gpio_led da850_evm_tl_leds[] = {8 z, E3 a% r$ n) [/ _
{
8 h- A) ], W7 R9 @) S" }8 `. T! r$ [9 D- R .active_low = 0, t- R$ {1 F; m$ z |- x. u
.gpio = DA850_USER_LED0,/ B, f- N- A. D# ~
.name = "user_led0",
" ]% ~* k1 f/ C& m& x6 a! j .default_trigger = "default-on",
- M4 s1 Z# c* ]: S. m4 K7 K },3 o; N" n7 W/ b0 M: ~& u# r& h! e
{; K! i4 ~" }+ Q' } @' E/ a: i
.active_low = 0,
( R( P& i6 m: x3 R2 U1 Z .gpio = DA850_USER_LED1, w! x2 V m& v/ J4 F4 ]3 n
.name = "user_led1",2 g/ f, m7 G! ?: x* V
.default_trigger = "default-on",) ]! M! `4 S: V0 G
},; v0 T4 r& U- t
{/ u3 F( X( m, `$ E5 I
.active_low = 0,! @' t9 j# q$ z. t: J
.gpio = DA850_USER_LED2,- b! f3 J8 L3 ^7 C# \. q
.name = "user_led2",
7 z" Z( C* ]$ z) w. l, |1 j .default_trigger = "default-on",
! f* i0 _- L6 c1 h' k },
, s! b7 {) L7 w3 J8 ?% @$ w* E {
3 K$ ?' e8 N7 w .active_low = 0," I# N' U+ F7 V; I
.gpio = DA850_USER_LED3,4 s/ ^1 V7 o* a3 v |* B" z
.name = "user_led3",
5 j: Q! p. V0 w3 j: M9 w5 l" i/ `9 | .default_trigger = "default-on",
$ F* v6 F' x$ [" W P7 t },
4 G0 i" g9 R* |# j, U. d4 P; f w};0 t. a m9 r* O5 c- N
3 _3 \! n, U0 Z+ V, H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' U& E- `0 Q, [5 |6 w: Z3 s( v
.leds = da850_evm_tl_leds,9 N$ ?/ {5 j0 h& i) e3 Y/ ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' b! T. d0 z. ^7 a/ c+ c};
6 I9 H$ N3 R+ i6 J$ `& @# p5 G4 X% a( {) N5 k4 N' M6 h
static void led_dev_release(struct device *dev)' t' ^4 v7 k$ ?3 p! f
{4 p+ h1 u" c8 |# ?: }
};
, T/ p- x/ {/ b7 j) [/ Y* O
2 E- P, v# O3 l+ t9 g0 ?, rstatic struct platform_device da850_evm_tl_leds_device = {
0 S( \* P! G2 X( i0 |( \ .name = "leds-gpio",+ h& h( b: s/ K7 u w! n' E
.id = 1,
& s, w6 l" o! P .dev = {
% ?7 G& d8 n9 {2 r" V7 [1 Y' { .platform_data = &da850_evm_tl_leds_pdata,
- I; _7 h# S$ s/ j. I( T .release = led_dev_release,
! u7 `. [3 T8 B/ y) `- h }
0 ^) V* | j: s4 V5 ~2 Y0 S0 a};
. {9 ]" M( v& b' P& c N/ s2 f% f: r3 h e
static int __init led_platform_init(void)
& b, ^8 `! h/ ^1 D' x2 |{& C2 A) t, q- x5 d4 [+ B6 t4 n+ J
int ret;
, m0 ]* s4 j& v#if 03 k7 q$ y Z) j& }3 d# Q3 J# b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. g. Y! D+ y7 Q5 g* E' @( i
if (ret)4 b2 O. f0 H# T+ w5 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! C. K; p F$ H
"%d\n", ret);- z7 c* x% [% o
#endif
* Y: h2 y2 j6 K& y; ~& Z ret = platform_device_register(&da850_evm_tl_leds_device);
2 m2 g, [( n% P0 `: s if (ret)
" w+ [: {* j9 F) P0 R6 C pr_warning("Could not register som GPIO expander LEDS");* H- R5 h4 B% z" E5 Y
else
. g! v9 ?0 s7 X) W2 g* H printk(KERN_INFO "LED register sucessful!\n");' y7 L4 |+ P, E* m. b
5 r* I. L# K0 U* \9 L! K3 O0 D return ret;
' p; w: {/ _8 o* B7 M. c- G}
" v: ^- \* N% b9 N: I: J9 x9 R9 l m; R' t
static void __exit led_platform_exit(void)
: \' n( A; }* b- v6 O) |0 G{
5 |' q% }) J2 w+ Z; U( X platform_device_unregister(&da850_evm_tl_leds_device);2 Z2 k! W5 q; u% T- K$ g& l" [
- k+ B1 T1 g8 P" R* m0 f
printk(KERN_INFO "LED unregister!\n");
5 @6 W: |3 d! `3 G7 x}
6 Z$ c* }3 \ w7 B% K
) _% `" {, i4 B5 v2 f# }# Smodule_init(led_platform_init);1 z( k: j6 N+ G, G" t/ \! C& l
module_exit(led_platform_exit);
; H1 V' X3 @& e" ~1 f4 z0 \# X6 D- A# F! p+ n3 _$ \; B
MODULE_DESCRIPTION("Led platform driver");& O4 i1 r3 y/ _* B
MODULE_AUTHOR("Tronlong");( B; | u$ X% g
MODULE_LICENSE("GPL");
: S( _( q7 x* e( F8 G3 Y7 i/ \. l7 {0 }3 R, t1 b/ K& C# j9 h0 Y
|
|