|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ D- b- `& w" m' j6 N: X#include <linux/init.h>( N5 B2 g/ e3 _, i9 U
#include <linux/module.h>
& L" J; p5 T8 M; v2 @. t#include <linux/kernel.h>0 \7 J: F# I! A7 X O
#include <linux/types.h>
: Y! k o6 I) \. ^#include <linux/gpio.h>
- m! s* O p4 I& A) N/ O) Q: ?#include <linux/leds.h>
* [4 m, ^& d: |: l' D#include <linux/platform_device.h>
: B$ ^' P9 ^( G' t9 x
, b: V( r! A; G/ A% N9 L5 m#include <asm/mach-types.h>; ~; S P6 Y0 r$ V$ e
#include <asm/mach/arch.h>1 z6 T# b3 O- j' U/ R! o m
#include <mach/da8xx.h>
* z) m" G0 o8 p; M |#include <mach/mux.h>
% u0 E; F5 T$ K) l: _7 H: C4 V, \9 d& H, T( _6 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' P6 G" ^9 |# ?5 W7 k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 o/ ~# L$ L& N, w* f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
[8 B8 |/ m) H% b3 n% i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! J; e! t7 m$ z1 ]# I* ]
$ r# M7 U7 a* J5 r/ G
/* assign the tl som board LED-GPIOs*/ a9 C/ A7 i( Q0 N
static const short da850_evm_tl_user_led_pins[] = {
* [% _0 n& N) h- d7 J" z' O /* These pins are definition at <mach/mux.h> file */0 K* T2 U' @# u# a/ Q; Z4 ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 e+ \7 s4 c9 G -1
8 q. i5 i# Q/ Q; m};( D$ Y/ S7 c! c U
R- t6 Z0 \1 L5 x; K9 |- ^5 L2 Y% I. bstatic struct gpio_led da850_evm_tl_leds[] = {, s' E) Q5 K# i
{
' J7 F* H+ o6 O8 I .active_low = 0,
' g+ U3 N# y" p& C9 T) k .gpio = DA850_USER_LED0,( e ^( g7 R# U
.name = "user_led0", k7 R2 x0 c# ], c" |- o$ G& {
.default_trigger = "default-on",
% W/ a0 l/ D6 K) z1 m6 S },: C0 b6 j9 i/ F3 m5 B( Z- A. g
{( @4 w- G6 ?+ S6 G
.active_low = 0,% \; B/ z3 N2 X' m! u) c5 }; m
.gpio = DA850_USER_LED1,
5 K: I6 I6 v2 `+ X0 } .name = "user_led1",
) N4 [* P( R; j& T% k: q5 }2 A .default_trigger = "default-on",# `4 `5 x" ? x+ p& e
},
( x1 r% y+ O; _2 g7 ~* y/ c: c {/ `+ U5 |' h( y/ z$ A. |
.active_low = 0,
# l% J1 b; |7 {8 b% g1 M .gpio = DA850_USER_LED2,) j" V6 a& A# [
.name = "user_led2",3 Z+ `7 R) U! K7 g: Q
.default_trigger = "default-on",
0 {; ?& i% U! k }, `% |- t* X" y! ?8 R3 B$ O$ Q( s
{
, M8 y: G8 d* ~; m7 _; R; h6 Q1 O .active_low = 0,
. l' h P4 m1 X7 O; x* b" s" u( J. j! A .gpio = DA850_USER_LED3,& F1 j9 \2 q X+ K9 z2 f1 A, z
.name = "user_led3",. a3 |- k8 P( L7 H0 t
.default_trigger = "default-on",1 X# U' z( J D2 r& d6 N
},
6 M5 Y) n' @6 C$ g V};
" a4 v8 R3 L1 g) ]0 {1 ^; q$ [- ~0 U) K- G. Q3 d5 t; O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 S. @6 T1 q( [ .leds = da850_evm_tl_leds,# P; v2 w$ N; A' Y O4 _) f2 t+ j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 W9 t' k( [7 b6 v0 }: `1 l
};
! Y& l7 ?5 u: a/ l" y6 ?# e% o# L
static void led_dev_release(struct device *dev) w6 Y. m* u( F$ B- e# A2 i
{% H6 M; {& M, |, W
};
. b. M/ o/ D! j, q. |3 Q
/ [3 U0 i8 a+ Kstatic struct platform_device da850_evm_tl_leds_device = {
$ o& |" Y2 X( P% y3 V7 h .name = "leds-gpio",( k: X& x: C! T
.id = 1,/ F+ O2 `) T+ H: _) ?' y, }
.dev = {
3 o, N( ^) k. |& e$ v% C2 ^ .platform_data = &da850_evm_tl_leds_pdata,$ B ~* L: G) Q& E9 e7 ?: a
.release = led_dev_release,
1 U% u9 `, }/ ^* C" |* H0 I }
3 G! M* e% U; w X};
' [* t" y) w7 `8 v
9 V$ w0 G; C! m0 Mstatic int __init led_platform_init(void). p& Q6 N4 _7 p5 k
{
- T" b% a Z- g9 D% X. j7 @, }1 d int ret;4 }4 \3 [% l4 c# f4 e
#if 0
6 s/ \$ K" _) t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 z+ [: _8 N, ~ if (ret)
" s' S! P* R5 a+ F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- _1 C$ U* e' U( y4 U. o5 p m c "%d\n", ret);- z* A {& [ @& D9 k a4 Q
#endif3 C$ S4 N. V1 g. t1 I
ret = platform_device_register(&da850_evm_tl_leds_device);
4 m' h( ?" R& `/ d; s if (ret)
7 Z+ Z* A( w, l8 j pr_warning("Could not register som GPIO expander LEDS");, R0 F# R/ C+ c7 B! E( N
else
2 Z, a |, P# {7 J( U printk(KERN_INFO "LED register sucessful!\n");
( R4 R; p0 H& ^' r
3 Y# t3 }; O& M! q' H8 | return ret;& P( k3 ]4 `9 D1 k) k
}- N9 R+ u; }! Q: u7 x3 P2 h4 ?
/ Z! [) P( R9 w; }4 b. {2 s0 H
static void __exit led_platform_exit(void)- Y7 k7 h8 O0 f2 Y9 P
{+ y6 F# Y# s3 k( H
platform_device_unregister(&da850_evm_tl_leds_device); p3 L J4 d H/ H: P" S H& K% i
8 U* z6 i; H7 X6 s8 p2 P printk(KERN_INFO "LED unregister!\n");
& s! _( o# h; G, _7 L}
2 Z( ^3 m J O G
# _9 s# O, Z# S! Z- v+ t# r$ B1 M# Dmodule_init(led_platform_init);
# {' d+ [! R) x1 N9 umodule_exit(led_platform_exit);
9 M3 `! B/ @4 z8 v! z2 C9 s& N+ X0 z0 T. t: G
MODULE_DESCRIPTION("Led platform driver");
' _/ f! B7 @* A, P. pMODULE_AUTHOR("Tronlong");
! t3 Q5 o6 V1 }* T* E5 FMODULE_LICENSE("GPL");
* _" \) J' D3 b2 z- H0 g! ?* g5 P# b1 n% z# f. x7 W0 W
|
|