|
|
求大神给下面的程序做注解,请稍详细些,谢谢。$ ] ]' B$ C% c: |( p7 J% `7 ]
#include <linux/init.h>
/ R/ ~$ d$ o; h#include <linux/module.h>
8 u4 c+ d; t% v" C#include <linux/kernel.h>% t! S5 v4 _! a4 [
#include <linux/types.h>% [# v G }! i! `$ T2 m4 f* i S: N. j
#include <linux/gpio.h>/ ?- _7 T$ L. w, n3 Y
#include <linux/leds.h>
5 G, u2 P. n w7 i# l#include <linux/platform_device.h>
) f. t4 o+ e! F& [: S% b. h* `. o7 d( x" [
#include <asm/mach-types.h>
, K. q7 R m$ J; j8 ^#include <asm/mach/arch.h>
: v6 ~& Q- I3 y- A$ s1 y#include <mach/da8xx.h>: b9 V' X. }& Q3 g
#include <mach/mux.h>
: L. e9 n& t) v! K! [2 A" ^( d2 Z* t1 X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( l8 k2 ] X1 [: M: E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 I; A& l J6 U f! ~: f( H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- P/ u* s7 U4 c- G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( r) K" |2 y2 v8 e, V9 Q/ T! n9 y( n; ?
/* assign the tl som board LED-GPIOs*/
; n) k( n8 [$ [' e8 o+ B$ wstatic const short da850_evm_tl_user_led_pins[] = {
5 B8 o- P! I @4 V8 |; I/ ?+ w; V /* These pins are definition at <mach/mux.h> file */
3 B% f- U1 s, e/ X' D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' G# P9 E X+ E3 n, p, C -17 p! U5 \) O& ^ h7 e3 ^
};
6 {- f z" U! O6 F5 L& J2 `' b) ?* |; s3 m* _ J. N' I
static struct gpio_led da850_evm_tl_leds[] = {
/ B0 d6 ~4 T s$ E7 t3 i {
/ ~* Y3 t/ i- i: s& W9 b& d* d .active_low = 0,% K# B2 ^5 ~8 ^0 C
.gpio = DA850_USER_LED0,2 v; O( o4 r" S4 Z& Z; h
.name = "user_led0",8 O: _$ {% v3 p1 N
.default_trigger = "default-on",
; l! v6 {, h/ u },' L, V; E! z7 n& B$ o
{- Y' t, `5 u! |2 u8 W, E. d2 x& g
.active_low = 0,7 f) c% x9 p& w2 N6 }8 j
.gpio = DA850_USER_LED1,% c H! Q( O7 F1 `: e t. e
.name = "user_led1",& E4 m0 J a v2 w7 f9 v. Z5 o
.default_trigger = "default-on",
) F" b! [) R% M# g; g5 Z4 a },/ F/ W" x' R& F* h2 U; R
{
0 v, B1 V/ [' V; w. U9 v1 \- a; ~9 r9 ] .active_low = 0,2 {2 H- K- O: R
.gpio = DA850_USER_LED2,
3 D3 e1 @7 B( k .name = "user_led2",
6 p+ }* a$ n8 R .default_trigger = "default-on",
, b2 _/ l6 i: `/ @( F) e' n& O+ D },
% P7 N" l, s2 k" U. Z- d# K {
: E- }. Y9 |6 s .active_low = 0,& w* B6 ?+ J# J
.gpio = DA850_USER_LED3,0 H1 X* E0 J$ b
.name = "user_led3",
% H7 O% G9 k2 N. h: I .default_trigger = "default-on",8 {: y. r3 U' r. }+ Y& C# z7 }
},
' P: `: `, I- S};
- X3 c4 n5 g# B% {: a) R! R& n+ }* H% C& S; U
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- s- P/ d# I3 U, ?5 b" R
.leds = da850_evm_tl_leds,
. A" `9 [: ]) ^& K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 r X2 o; V3 m; o! w' k) g8 b5 h) r
};
; a( |6 O$ e4 n! w
- m! x0 \* P7 Y5 e6 c/ jstatic void led_dev_release(struct device *dev)# k- }3 d/ _" @ P' Z
{2 r* K/ w" U+ Y5 \; q$ e
};3 m( S' t' }8 |! K w' {- X
% l+ t6 d1 P! S% _- }* Gstatic struct platform_device da850_evm_tl_leds_device = {
$ ~6 ?+ ? e0 r2 U) D% g .name = "leds-gpio",; d, X% L2 m* g9 }
.id = 1,
" Y6 \$ b; K3 A5 V2 I9 ] .dev = {
8 W& `% y" `5 R3 b( Z .platform_data = &da850_evm_tl_leds_pdata,- }4 e3 ?6 m2 L8 L
.release = led_dev_release,
0 k* @9 A4 L6 S/ l8 }, {& @; [8 V }, d8 Y. i3 y+ ^8 E0 L: f
};
9 T7 Q- }- R4 _: _! g- g1 i
) n6 X) }9 z# }static int __init led_platform_init(void)
$ }5 ~7 ^5 o) O0 B. U9 Z; M+ H2 P% r{. A& y# e9 F+ q8 X' O
int ret;
/ j& v1 n! |9 i# Z) t#if 0
3 _$ y9 x" T4 H' }8 I" X% [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 d" _: z1 Z7 J
if (ret)/ W! ]; o! z* q8 ~: ^9 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" c+ V* ?& r" Z6 ]! f1 ? q4 V# _ "%d\n", ret);
. Y6 ?/ I( E5 x0 V: k. h' F! w#endif9 i5 R4 ^! L4 D7 N8 d) C$ i5 ]& ~/ M
ret = platform_device_register(&da850_evm_tl_leds_device);
# L' e; P/ ^! \5 O4 o if (ret)5 M6 t: Q# t( r, K
pr_warning("Could not register som GPIO expander LEDS");
3 j. q: X2 a+ T. K1 Z' s9 O else
; q; g6 d6 c; b; o$ T8 O printk(KERN_INFO "LED register sucessful!\n"); s6 q7 Q' `2 ]
* `4 N8 j. O, _5 N: ~) [! z3 D' ]4 q
return ret;
, O' O$ O/ K) k: v6 H}
5 I' _0 \+ s- H) \" S( y
# G6 `; ]% y1 O- ^static void __exit led_platform_exit(void)/ u" f3 N6 v4 o* t0 w! Z+ @
{1 f" z- p. o( K# z# u( `. g
platform_device_unregister(&da850_evm_tl_leds_device);- c5 L e( I9 P5 O
% O" J/ j3 r% N- |- c9 [! m printk(KERN_INFO "LED unregister!\n");
- O4 q! h6 }$ F9 E4 B4 Y' [}
: S& G% X. E! L" P d9 t u5 Z; I/ Y2 j- R) F
module_init(led_platform_init);+ T. o# Z6 z1 c$ f" I$ R
module_exit(led_platform_exit);
& h6 R* O) h- F4 O1 N: k. D
( u. r0 k3 o' k# P/ [MODULE_DESCRIPTION("Led platform driver");8 R6 t4 z: ]) c0 u" P
MODULE_AUTHOR("Tronlong");
! u$ n6 l) h( \, R% J; L' K9 \$ lMODULE_LICENSE("GPL");
$ f2 { p v( E# Z+ S) o. {; @$ d! \& r) a6 \% a H P
|
|