|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# b2 H* f% F ~#include <linux/init.h>3 `% s- C" H7 T& l: d( ^
#include <linux/module.h>2 P$ x$ l$ A" t3 j
#include <linux/kernel.h>* T* _: P$ q [* t+ A
#include <linux/types.h>
4 n- a' E2 x4 H! I6 c#include <linux/gpio.h> q5 J3 d/ v6 j7 o# h2 J1 ~
#include <linux/leds.h>2 W0 |, b8 H4 ?: S
#include <linux/platform_device.h>/ x: u" r& X. \8 P
: H% z! {9 H) y* k- X& J#include <asm/mach-types.h>
6 f) B" z3 s2 G# I0 K# t9 q' u#include <asm/mach/arch.h>
- u- I7 { B* R# S# j! p1 u8 `#include <mach/da8xx.h>7 u' S: Y/ y1 C
#include <mach/mux.h>7 \: N4 K* h& W2 k. \( M& v: _5 B
: y8 Y4 |: k, m9 r6 Q! q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( c+ `( C% @% e1 ]* F$ l1 A& }6 ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' [/ @. x, L n7 N3 w4 N0 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) ?; A/ A$ K% Z7 {; ]: w9 X3 g9 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 ^8 m% f, u: U7 w9 m
1 V N7 R% C0 N+ t* u/* assign the tl som board LED-GPIOs*/
# s4 e* v5 o9 |8 O/ |6 f/ K. ]+ W. r. u. ustatic const short da850_evm_tl_user_led_pins[] = {" e, k/ V+ N. T
/* These pins are definition at <mach/mux.h> file */' g7 O$ B' `* P' s9 y: E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* D& G- S" \7 J" n
-1# n% W+ N6 Y7 Z4 h/ W3 x# ?
};
4 i3 N$ G7 R; q- ]8 [' m5 {5 T9 W& ?/ z
static struct gpio_led da850_evm_tl_leds[] = {' K- z& c( w1 b7 L) b7 I
{
! m' c) ~; K( B .active_low = 0,- u+ Q% I+ y, V0 }5 n# d
.gpio = DA850_USER_LED0," G# r9 Z- J6 P" r
.name = "user_led0",
, M1 I4 [7 x4 ]5 n .default_trigger = "default-on",8 G: h, b' ]+ G
},
2 s1 ^& q+ a9 H0 ]& P7 H3 P! c {
6 ~( |2 P1 L& i6 s3 M7 c .active_low = 0,) G& | X+ F% \" p
.gpio = DA850_USER_LED1,
( A- G: h' u0 A: M .name = "user_led1",2 D1 s1 L" O% i3 B- d/ _
.default_trigger = "default-on",8 ~- k8 G8 a! \
},
: p+ r! }+ ]6 D! X8 A {
% n, K( B# M% Y0 ~+ w: R .active_low = 0,
& u% R( D' W9 z; P .gpio = DA850_USER_LED2,. C S0 H) [* m. c
.name = "user_led2",: |+ x" a9 v' y7 n4 G* T0 D/ j' `% a$ P
.default_trigger = "default-on",6 z$ t6 p+ f5 E- F
},. z, r \8 L- x) S( @
{. m6 x* U* [3 M" x; S
.active_low = 0,2 x: h0 U7 O3 y9 u$ A; z
.gpio = DA850_USER_LED3,
; |6 ^ C0 h# L- ]4 C .name = "user_led3",- d# j6 f7 h( S" U( ^! i% {" F
.default_trigger = "default-on",2 _' g8 S4 o- S4 ]1 @5 b5 f! g
},
, D8 _" S/ O7 j# t1 R6 j};
) R% c! S/ u) O6 ~& v
. q* n1 e z) g/ ]& {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 h* q+ e: I% b7 T0 r
.leds = da850_evm_tl_leds,
0 s1 X& t* a* o: A0 X8 F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ Z3 m3 V* p4 u; [% d% n k) e
};) U) B3 j5 S3 N0 g" w! S* T2 `
1 E# A/ t+ K6 W( Z9 p% W5 K( P" ystatic void led_dev_release(struct device *dev)! l4 _1 R% O/ z# @) C7 ]
{, O9 n& H. B6 B) o5 z, m. l- E! H
};
4 Z0 {% U f4 Y8 E0 p! h$ k) e9 @2 v# E! V1 o3 ?
static struct platform_device da850_evm_tl_leds_device = {
) T! p" G+ b0 |, A8 U .name = "leds-gpio",5 l3 F; v9 M0 J0 B4 ~1 _
.id = 1,
$ R" d5 x0 x P) D .dev = {
! z9 Y3 K8 a6 z4 `8 {( A .platform_data = &da850_evm_tl_leds_pdata,
* S) Y5 l% ?2 K- }- v$ [( q .release = led_dev_release,
' h9 w! x/ {: s% h1 Q }
L* N9 m1 U$ W' M& l' Y/ ` F};5 U' v( ?2 }: b6 {& L4 O! Z
" t Y$ j9 w- k5 M5 ?! o3 dstatic int __init led_platform_init(void)+ p9 a8 N& Y/ |. a" {3 D8 {: u
{
3 B8 `3 f' k; b' L3 [ int ret; h& y# N2 A/ T% R4 c" j9 z$ U0 E9 G
#if 0
, {. u0 ^0 B/ \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; d7 C5 ^# g6 P. |
if (ret)
; j0 `2 u6 a1 U+ J& D1 x2 J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( |4 `. ]$ l, E, G "%d\n", ret);3 H1 `, n* m l% [" k3 y s
#endif2 F4 b s" ?6 X, n. z9 Y% c9 N" {
ret = platform_device_register(&da850_evm_tl_leds_device);
' @/ D+ L; t$ l. k3 r if (ret)9 M2 c/ s `2 k
pr_warning("Could not register som GPIO expander LEDS");/ V" q4 E7 }# i
else
8 s8 N/ g$ V! w printk(KERN_INFO "LED register sucessful!\n");* j) a1 @5 k1 w o& S. Y; X
% @" E3 x \; [1 Y return ret;$ U$ w& ^/ q/ q, L
}" d4 T* D% ~2 t8 Z
; s* T6 [) L) t2 r
static void __exit led_platform_exit(void)
: ?! _2 H2 @ ?/ [3 m" N{
* n, @$ f& E$ M0 ~" t" o0 f0 ~( j platform_device_unregister(&da850_evm_tl_leds_device);
3 R E( s; o; ~1 N- \
! A# D" A( z- r( f( X1 C printk(KERN_INFO "LED unregister!\n");
' O+ N3 j1 _" s" X J+ t8 w) O}
- m% f6 n4 s) Y. V! [9 l' Q
: W$ }' V4 S3 ?/ T% T" Z% Hmodule_init(led_platform_init);8 o; @( @- x% k1 A, i$ c6 q
module_exit(led_platform_exit);
, K; h* m: i4 M
$ h, u0 B# Y/ s5 [6 ]! KMODULE_DESCRIPTION("Led platform driver");: e: u9 ?; a: R
MODULE_AUTHOR("Tronlong");! F! V x" g3 e' P$ N' S
MODULE_LICENSE("GPL");
5 D; K* \1 y1 b0 O. e; p; Q! ?& J( v L& U
|
|