|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 Y, s* V5 A5 ^+ H8 _$ ?
#include <linux/init.h>9 [* z( S4 F8 Q3 t m
#include <linux/module.h>7 t* P: J9 z5 N- w/ j& X
#include <linux/kernel.h> z7 K) @2 |8 _& t4 V, b5 a3 J
#include <linux/types.h>2 Q. S6 D5 W0 z: L" S
#include <linux/gpio.h>1 e: Z5 |+ j5 |! S' ?
#include <linux/leds.h>9 D j' V H+ u" s7 c9 }8 n. r1 J1 k
#include <linux/platform_device.h>* P3 ?3 D: s; E
: b( D! N1 l" N, Z) K$ l/ a
#include <asm/mach-types.h>( [/ o/ X& k: M6 ?; F& Z5 u' N* S+ v
#include <asm/mach/arch.h>6 F$ d, n, ^( A" @; ~1 w9 ?
#include <mach/da8xx.h>
: v9 ?& _8 I* B4 S2 @#include <mach/mux.h>; ?2 N1 w+ N8 ]. P
+ Z% L- t7 n$ b. i, \: R3 d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 t Q* Q. Y" }1 n$ ?/ O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 X' Z' B- M4 o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, J* d& T3 B- M$ m2 c; [8 E2 y9 q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 \0 B. m# a# R0 ~1 `7 A$ Z
( e( L& J# w. M2 n) `/* assign the tl som board LED-GPIOs*/; |7 Y" M- z" b* P
static const short da850_evm_tl_user_led_pins[] = {/ Z( B Y% o3 q! B
/* These pins are definition at <mach/mux.h> file */3 B2 J& n& v; q0 o8 Y6 U' {+ Y( F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 f7 t$ g" o6 D& H/ N# q9 O6 Q, l2 o p -1
( v- U7 T: ?. x! | ^) P3 n+ N* B};3 U$ S" G. @5 \
* L/ j0 [, \1 e& hstatic struct gpio_led da850_evm_tl_leds[] = {6 t' O: u Z7 a
{
0 V: t! D1 [3 a8 m2 c .active_low = 0,
3 x: C, V% M# G( L+ t% Q" t1 R5 R& a .gpio = DA850_USER_LED0,; L4 N$ x: P! G5 z
.name = "user_led0",
E! Z$ u- Y) Q/ `8 V7 M .default_trigger = "default-on",8 i7 a. z0 W! _2 }8 y9 M+ u
},
. V3 s1 [# w9 r: t' _ {
' U7 b8 W6 L" w$ e0 E' u .active_low = 0,
- W4 Q8 [3 H+ k) {% F .gpio = DA850_USER_LED1,
7 x6 Q9 J+ l, l5 |% N .name = "user_led1",
5 {- N+ G: i! `! M9 d .default_trigger = "default-on",
2 {4 r, M9 z3 f, y },( T) X" A/ R W. i
{
0 X3 U6 R/ H- V .active_low = 0,7 a# A: p* R& K* F
.gpio = DA850_USER_LED2,7 y S' I/ m# _+ n% i5 P
.name = "user_led2",/ u% M3 J: Z, I" E8 q) k7 a
.default_trigger = "default-on",
3 \* G6 ` l( E9 M; o; r+ d* R4 |' J: W7 r },* C! [! q& I8 W: T% C
{5 N. U8 q/ O0 F: G" P$ d
.active_low = 0,
6 G% r5 t. B1 z) D .gpio = DA850_USER_LED3,
2 U" Y: y8 R) Y" ] .name = "user_led3",
" q$ b1 q% T' `5 t2 c .default_trigger = "default-on",( | l4 z" K2 a9 O' g1 }
},
: m) \: K/ o0 `+ i};' U, N1 H5 T# K! _7 [
7 ~3 \. i8 h& E7 ]* Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, @" y2 F g# q8 Z .leds = da850_evm_tl_leds,7 j( f" S- K4 ^( }. Q; Z3 j: j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ i; ]5 j' f0 D% W! n- M3 {};+ Q% ~/ Z! b) a( C
: d% d1 B4 R5 {3 z; O% G9 M" Y) Astatic void led_dev_release(struct device *dev)8 u" R* h7 P, I. a2 W3 H& C
{
- d* p- l9 a/ M6 @- i# U( R};0 V* \, [( @ H, i; i
. j; o( s8 s/ _9 `) M/ O0 sstatic struct platform_device da850_evm_tl_leds_device = {2 U, K. b8 E; C8 ~) Q
.name = "leds-gpio",4 C# V- g! o" U9 Z/ e7 M+ i- [
.id = 1,
3 ~! V& d, X# I5 H* S .dev = {& G. i1 | v9 l
.platform_data = &da850_evm_tl_leds_pdata,0 ?- E. S: L4 `( E
.release = led_dev_release,
6 C' {% J& ]1 B5 R$ U }! k1 a5 y, i- w# z, K) W
};, A7 X* Q8 E) o" \; X( w2 n
5 L! z7 @7 d" h! M
static int __init led_platform_init(void)
- h* G; A e% ~& u' S8 @ F+ X{
0 d. Q" z `5 a) L& S/ O0 ?/ r- z3 C int ret;' Y5 X3 t2 Z1 A) @; S6 R) P
#if 0
# Q) c- a+ F/ K1 ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 \; I! {3 w M' ^9 ], }$ o/ P
if (ret)' A& ]9 d* E+ H, m) e7 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" Q B4 K% [( v& i, R' L "%d\n", ret);
& ~/ E3 ]1 H6 P#endif
/ ~3 ]2 Y3 \$ B" Y# y3 S ret = platform_device_register(&da850_evm_tl_leds_device);1 b; n4 _" | W: I+ Q: s% |
if (ret), o8 f7 z, ^9 G/ {6 v# S
pr_warning("Could not register som GPIO expander LEDS");
5 b1 B: }7 L9 X7 A" M9 K1 U. }8 F" \ else. H$ O+ J _! }
printk(KERN_INFO "LED register sucessful!\n");; E0 \3 X# c* m
0 L! p+ t% U/ y return ret;! V- L" w* F7 z; i% O# j3 ?0 T3 z: g
}
0 i2 _- P$ ^5 f5 D r9 C8 ^
7 y y* B' }6 [" J; X0 \static void __exit led_platform_exit(void), X ?. ~6 e5 ?$ ~8 f
{
a) s8 D$ v6 B/ |$ f. u platform_device_unregister(&da850_evm_tl_leds_device);; o% E( m$ z& a) e
- p2 N2 V0 o$ k, I. l4 P: I printk(KERN_INFO "LED unregister!\n");, X, A$ E# ?! W# v% T, G
}
! r% Z" H+ ? ?; T. X, S% _1 ^8 f+ ?: G. ^
module_init(led_platform_init);3 f8 ^! N/ u- u7 Y8 _) U. e
module_exit(led_platform_exit);4 |0 z9 B" E) {9 C5 _; V9 ^0 L6 U2 m' `
" F; ^! A( h$ IMODULE_DESCRIPTION("Led platform driver");& {+ d& F. b0 w5 a" Q/ L/ |6 }* y
MODULE_AUTHOR("Tronlong");& J* i( j* T4 l. a( a' e0 w
MODULE_LICENSE("GPL");
$ A5 b6 C& s" ?2 \- q- F. Q
# @% q' t5 [2 p2 @# u |
|