|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 ?2 W1 m) u r& v% n
#include <linux/init.h>! a9 q) W, r6 [) Y
#include <linux/module.h>
; t4 M% O7 |7 N/ n3 J/ c$ T7 N#include <linux/kernel.h>
! n6 q. m: n! \# o) E+ r#include <linux/types.h>
5 d- S f& x0 p: k8 y#include <linux/gpio.h>5 S: t- ~* h2 S. `% @( y5 |* G
#include <linux/leds.h>2 p4 k. X/ i( P+ |1 E9 G, `
#include <linux/platform_device.h>1 ?) X5 T2 a2 n1 F0 I5 l5 [
4 T0 r2 B& k1 ?/ F p
#include <asm/mach-types.h>
8 E: L( o8 o7 i& R/ y$ w8 n: y' g#include <asm/mach/arch.h># g$ U6 D* p2 U& {7 Y- x p
#include <mach/da8xx.h>6 v% N6 y. K/ Y6 k( a0 [% @
#include <mach/mux.h>
* B+ I7 z" T+ y1 Y0 x ]' g0 X- d ]4 _; |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 ]! n* }: d; w2 `6 v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ l% L4 I0 }/ x X t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ D) m# B- C3 g( [2 b9 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# r0 ^, s: n& N9 t2 \; K6 ` a8 H9 ^; j$ Y) B5 D/ @
/* assign the tl som board LED-GPIOs*/
! b0 [1 P/ l( W+ ]' a8 v& Gstatic const short da850_evm_tl_user_led_pins[] = {9 x) O! A% Y7 k( y+ [+ G& l* l
/* These pins are definition at <mach/mux.h> file */, D$ g" Q$ n8 _' l3 D8 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: n0 S: w M, ?: M- {1 Y& V9 ?
-1
. c0 e# Z$ n2 |& v/ f6 T};
6 {& l% z9 S, [
+ P- ~. S: A. P9 ~9 l# Z! bstatic struct gpio_led da850_evm_tl_leds[] = {- w; n* n/ {( a+ ?5 \' {/ d: [
{
& P6 i3 x9 q/ A# E .active_low = 0,
3 s. y+ O1 P+ h5 @) S .gpio = DA850_USER_LED0,
. L- `, X+ w) L! q: P .name = "user_led0",( t4 b# B0 m& Q
.default_trigger = "default-on",2 c5 K, C( K$ v$ |' u0 g; c
},- S( X: X; \( D% e$ l, w- m
{
& {5 T5 |: z( | E( W8 l .active_low = 0,3 F# n2 u- ~% I' d* ^5 f/ h; f) L$ h
.gpio = DA850_USER_LED1,
7 _& v) o" ^4 a) e" J& I .name = "user_led1",
9 I1 f& ^& B' ?- V0 B .default_trigger = "default-on",
) K5 p: @1 u5 N9 b t },) N6 J8 S- \; y% z, m
{
, y2 T1 K% b# o$ r. |0 U .active_low = 0,
9 P) T* E K. Z9 K/ g8 s .gpio = DA850_USER_LED2,
$ m2 {0 P' G: y8 Y8 g .name = "user_led2",
7 _& U2 o0 ^8 R4 K4 |& H .default_trigger = "default-on",# l. z6 a! y7 J2 x2 w; x
},
/ ^% j" _ `0 n8 D {' ~: `* C9 _% H) r$ @3 i* {/ Q
.active_low = 0,
& J. `+ C8 V6 ?) o$ |) B .gpio = DA850_USER_LED3,
6 |: L; w$ e( T5 E0 |4 ~ .name = "user_led3",! C4 B& Q1 r J, L# w* n
.default_trigger = "default-on",
% l9 Q, ]- q1 H },8 x9 ^( p6 B6 o2 p& \1 ]" ~, m! r
};& k' n2 e' M+ J$ \- s! a. F' A4 @
6 o1 e4 w. g) rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
_2 S. @; r/ @2 m1 B .leds = da850_evm_tl_leds,% y; `9 ?1 I. v- I5 ~; e" x( Q2 i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) z4 C: R, `( r* B' r};1 I7 ~" n/ a9 h N; e% o7 n
1 Y% V0 H1 l, \& ~static void led_dev_release(struct device *dev)3 `3 a6 B/ n! ?* T" K- n
{( X; n% g$ T, A) Z. x. w
};) g+ g/ ?+ `5 |/ d" q( z# e% A
9 K* O$ s9 V( R& Gstatic struct platform_device da850_evm_tl_leds_device = {
$ d' G6 s$ I! B .name = "leds-gpio",! ~' W0 a3 U- S _/ \2 \
.id = 1,
- J+ H$ r4 B6 L .dev = {8 I! V% ]7 i+ l+ W1 i- Y
.platform_data = &da850_evm_tl_leds_pdata,+ V* W" ^( f- ~
.release = led_dev_release,
1 k* ]4 G7 M- F4 }( J }
! [% k: w: d: y0 `" X+ X7 c};% k' w$ z6 ^+ ^. M
1 a7 f" Y+ H+ \( Gstatic int __init led_platform_init(void): D z& d5 [# P( P! A5 q
{
" s% v: d9 I9 @: Q& Y int ret;! M% X8 O' N; u% S3 X7 `+ k, {+ n% X9 ~
#if 0
$ Y, o. ]3 i0 A1 z3 j- v/ o% k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" f0 h; A/ O! q9 @ @ if (ret). T- z! ?% b+ @( m; W1 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, W8 c) i; e1 ^' m- I "%d\n", ret);. Q8 B8 U5 S6 b5 j
#endif
P3 R1 ?6 H4 X4 K+ [ ret = platform_device_register(&da850_evm_tl_leds_device);' A9 b, p) @) }/ H
if (ret); J* k. B' Q* m9 N5 i- }3 o- L* P
pr_warning("Could not register som GPIO expander LEDS");
: Z$ @0 H9 b+ M7 {5 w else/ W. @2 _: T, {
printk(KERN_INFO "LED register sucessful!\n");0 S, q# q( Q& e/ ^0 k; \( C x
+ M0 z3 W g# m return ret;! a- R4 W/ b# g* ?. ^9 {9 C' R
}
, {4 X+ b. c. {( ^
- y: T2 ~/ H8 n9 [static void __exit led_platform_exit(void)
& t1 g5 P' a+ h) K' c6 J0 Q{2 W) j5 Y: j3 k! n7 ^
platform_device_unregister(&da850_evm_tl_leds_device);
) Z9 }3 [8 T) i( p
$ v; A5 l# a, \6 X+ n Y printk(KERN_INFO "LED unregister!\n");$ J% M) X8 Y% `% A3 F
}
0 g* q3 k9 z" C+ j2 A4 E
8 b. i( \" g& g$ H0 x7 w( m' X( Rmodule_init(led_platform_init);
/ T' Q2 _4 A) l# x5 _, emodule_exit(led_platform_exit);* g8 \* Q9 t9 s! A, _" E1 E
* L% F8 i8 F2 M' SMODULE_DESCRIPTION("Led platform driver");' R% P' o! R# [2 |
MODULE_AUTHOR("Tronlong");
v; j1 t& n7 m$ l, GMODULE_LICENSE("GPL");, o ^$ T% c: ~5 U# M1 }! O, f
i' _' }1 P& [9 H* [
|
|