|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" [( p# K) X5 a: G7 L5 {: ?' r9 G#include <linux/init.h>
/ x" ~9 T+ z# h, [* P( y8 K#include <linux/module.h>" G8 s% s# B0 ?
#include <linux/kernel.h>
2 a0 i4 R5 j3 ~7 w# h# c! K#include <linux/types.h>
8 [( U& c, x3 J4 O' s' H& S7 Q#include <linux/gpio.h>4 i$ T# T0 N' a* E% o
#include <linux/leds.h>0 O' Y$ Q4 \/ P0 J) m( {6 p
#include <linux/platform_device.h>6 J# u, U0 W0 F! o( X
9 _1 E m) T5 _
#include <asm/mach-types.h>; R7 [8 v; j) z1 R% H
#include <asm/mach/arch.h>
* h1 X7 l& r6 m& y7 O#include <mach/da8xx.h>" B2 ?$ c, J, u6 x( j% P$ S- i
#include <mach/mux.h>
7 G6 \/ H% H* Q6 T: m- M+ A
: f. t3 D, o& G3 ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( U- y q( Z; J$ J7 b- H
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); }; t% [1 _6 c, F" W8 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ o" d7 J/ w) c8 V7 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& {" [2 V9 w& N) y1 ]1 `
) a& v( |3 E6 ~5 J6 A" l/* assign the tl som board LED-GPIOs*/
; U3 r7 c% {, o9 J8 cstatic const short da850_evm_tl_user_led_pins[] = {
2 L" p4 r# r3 e& [* c3 J /* These pins are definition at <mach/mux.h> file */; A9 L9 m6 I% w( }* {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' ~; k+ G: A1 {' X0 a -1! ^- w* O$ `# Y4 e! v8 G( l
};
5 U* n( ^( ]2 T6 a( D* |: Z3 m
# W1 z( P: {" O( D, Zstatic struct gpio_led da850_evm_tl_leds[] = {
9 e/ w3 {& P9 T P" P; _2 c {
W/ M( K v) Q5 G4 D/ R& {9 B .active_low = 0,0 Q& x$ y1 Z$ N& x1 ^7 R! K* b* [
.gpio = DA850_USER_LED0,
$ g( _6 p& W6 m+ B9 E, e .name = "user_led0",* ~# V4 u- j* C4 ?' ~1 \" s
.default_trigger = "default-on",% e8 G3 }, P! {# x+ _+ R
},# ~0 s4 N) ~, k
{
& u# Z3 w* x+ t u" b .active_low = 0,
; P! ?+ X% k) O$ u8 ^; h, E" ~ .gpio = DA850_USER_LED1,
0 S) {4 f* O$ Y+ g6 X% a$ K+ P .name = "user_led1", d) v. h3 E X
.default_trigger = "default-on",
/ @) Q% ?: f5 _) } },; b, ` a0 X. q( `5 |, [
{
8 E* Y4 P- P: L4 Q1 L9 [4 b' ] .active_low = 0,5 v8 S* ]) }. o, r8 l
.gpio = DA850_USER_LED2,8 L; O" z: M" G- ?& e( D9 |
.name = "user_led2",
; J v- p) g0 t( b4 u- i .default_trigger = "default-on",
0 Y( W: w k: w J( m* W },
; ^% n; ?: S1 B! c( I" n( ]! Z {
$ t# E D: [+ c .active_low = 0,! E* c; p+ N0 `& y |, [
.gpio = DA850_USER_LED3, t1 {1 ^1 T& ?1 b6 q* ]
.name = "user_led3"," K, f" L- d! l, U, c K
.default_trigger = "default-on",9 K, E+ V+ O1 c1 C
},6 l" c$ e) W5 G8 g0 A& ^
};
2 b$ Q2 l; J) h" l' W8 ]! ^. _! Q4 a3 `9 N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {' n* f; U5 k' o# i& B
.leds = da850_evm_tl_leds,4 E5 \2 @5 B( q p$ K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- m& a1 j9 \$ U* Y" u7 V, E' j
};; I c. U- t Y4 p, `
( B9 W6 q3 t% `9 @3 x8 Y
static void led_dev_release(struct device *dev)
) _' p1 Y" h' ]" m0 h6 t! T [5 {" I% I{
, j5 J V2 Z7 j% D2 @: p};; Z5 p$ j0 Q [0 j0 a; e2 ^+ O8 g) o
" h! r( @* N4 A' u, [' U3 ]static struct platform_device da850_evm_tl_leds_device = {
$ |1 n/ u n9 \, M2 ? .name = "leds-gpio",
6 A$ a! \! q5 ]; q: h .id = 1,
/ ^ x% l! g& \5 \ .dev = {1 c$ s' N8 Q% m/ h0 v
.platform_data = &da850_evm_tl_leds_pdata,
! `2 S3 t: L3 y# _) Q/ q8 u* f .release = led_dev_release,
. V; S+ \- n3 m, w# C }
% V( e/ v+ R/ f' C7 m. Y' W9 R6 }};5 t: V, |( R8 c/ I
" \5 I6 l0 w5 a+ |0 j$ M- V! F1 Jstatic int __init led_platform_init(void)# u) m: D( v: \1 o$ H
{
5 `) V8 a1 {+ l- Q! C. g int ret;
- T' h6 F7 ]' }. Y) P#if 01 ?5 n" g. V2 ^6 B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ B$ m! {9 K9 F# P ^5 i
if (ret)- |+ j# v+ D: r8 W9 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", { p: }% R& k$ z
"%d\n", ret);
v, r$ S8 ^' R+ t6 Y! U1 r# H#endif
; C2 [9 X. d" M1 a' S0 s0 S0 a ret = platform_device_register(&da850_evm_tl_leds_device); [1 T2 l1 Y" N% T+ e7 `6 ^. |
if (ret)) y9 Z% m$ c0 Z/ r3 }$ E7 j$ [7 V
pr_warning("Could not register som GPIO expander LEDS");! G6 s+ T6 g: Z. a6 h* Z! W
else
/ |# `0 C6 n9 Q- j% m' i$ r printk(KERN_INFO "LED register sucessful!\n");( T) o" r: ?6 F# b6 F! ?' ^% E& v
# m" \- P0 z5 T! o t& z
return ret;
+ O1 W4 O3 z& G}2 {( ]( |& x' q7 }5 J
" w9 m" Z( h6 r' {% Zstatic void __exit led_platform_exit(void)
1 A4 Q. [- d( y$ M4 B: `) c{
9 y7 _& t5 m9 d platform_device_unregister(&da850_evm_tl_leds_device);
% i$ m: u' Y/ O' {# w- @* P# e: O+ v$ v, Z- R* F9 f! i
printk(KERN_INFO "LED unregister!\n");
( l0 T0 o, A% F* U( |+ p6 Q' y}
* T3 E& e6 v( L, s% M# X& |* b* \8 B9 X
module_init(led_platform_init);6 }3 M! _1 H0 h6 L
module_exit(led_platform_exit);, y9 `' Y, d1 W; D. T- C
; q' A; l7 n+ ^
MODULE_DESCRIPTION("Led platform driver");8 E; h$ e) ^% M1 j' \ U) F
MODULE_AUTHOR("Tronlong");: D3 C6 c ]2 o8 c. K
MODULE_LICENSE("GPL");/ y4 F( W: E5 u
- w0 ]! T* M5 c" i5 S
|
|