|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ I& p5 j; u0 v2 h B: b/ \5 r2 I#include <linux/init.h>
+ j+ w" f, d* o3 }# s& {, z. b( y- N#include <linux/module.h>5 }: Y$ B8 ^' ~ [ a6 L
#include <linux/kernel.h>
6 B1 g) S, a8 [#include <linux/types.h>
2 ~8 R3 e3 L% D* m5 \2 Y3 @#include <linux/gpio.h>
! c% Q* X: ?, x8 O#include <linux/leds.h>0 c- z! C0 q$ S" p3 K4 A
#include <linux/platform_device.h>
! \# ^% l, I+ z F7 k& @) A$ _& _6 E+ |3 z, d8 K; M! V, B
#include <asm/mach-types.h>; R) Y9 w: i8 p% g8 h0 N
#include <asm/mach/arch.h>
G3 [6 O/ `3 H/ f. v2 }#include <mach/da8xx.h>2 R& C: ^9 s9 p5 ?! y8 c4 i
#include <mach/mux.h>0 O7 {/ V0 Y- C9 J$ L2 H
; {6 f' s5 @ o: R& W u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 j7 g& W# S# T$ i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 e1 X# Z5 }2 Y" V7 P- L$ n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), m1 ]# O7 p5 t& p: ~- B
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& Z$ \* W/ X: s% f( Z Y, P4 O, \6 I; ], }* _3 m
/* assign the tl som board LED-GPIOs*/
# M+ A* c7 L5 _static const short da850_evm_tl_user_led_pins[] = {
" \7 W+ H$ w' ~# h9 ~* L9 z /* These pins are definition at <mach/mux.h> file */5 H+ a7 `1 @ Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* b) M- X9 b" o0 H) E
-1
- t1 h1 e+ r7 f};
+ n/ J& S/ \: @8 l" r8 g% @9 w2 j9 Q
static struct gpio_led da850_evm_tl_leds[] = {
) E' X4 z; r, @/ h9 Y {4 u8 K4 O3 f, ^) C- I! U" V) r- `; E
.active_low = 0,
* Z9 _2 S2 G. ]$ @ .gpio = DA850_USER_LED0,1 z( g. u: _1 H9 K+ \
.name = "user_led0",
$ f5 m/ m! N. T# ^) E% q; Z; m .default_trigger = "default-on",
- [* [0 z7 ?5 x @6 ]9 ?/ o },
) R7 }' O! O1 `1 f4 t: n( l: y {
* |9 }8 k6 ^( H% J, O' Q4 [7 L .active_low = 0,
# T W* {1 A2 y G+ q* B& n3 K .gpio = DA850_USER_LED1,
2 G U: T5 J( L6 j) R; Q .name = "user_led1",; `+ T& p; F: _: `' o+ i
.default_trigger = "default-on",
( k! n. V) X; {5 L; ? },5 D" C$ O! E$ B/ O4 {+ `$ L
{
; O& J6 Y& E' ]9 A8 y .active_low = 0,/ W& y) D3 N5 S7 J; Z" q
.gpio = DA850_USER_LED2,3 ~0 K% c o0 {( U6 Q' j
.name = "user_led2",5 F, N- }, G8 N) o7 ]8 F
.default_trigger = "default-on",
. y+ m' @/ t @, h: H },
* G$ P6 y# y3 c0 o2 C {
6 i/ H7 g8 d5 C+ J2 B+ X .active_low = 0,
5 W' ~. w/ @; Y7 x: u2 [% u .gpio = DA850_USER_LED3,
" E% T" U4 R# P0 p4 x$ g. g. t .name = "user_led3",
2 @2 }/ s; U7 A .default_trigger = "default-on",6 A" w* P' O( X' W/ m# x& ~" f
},
, P8 D6 ^% q. j! f" j. n2 c};- g/ q2 X1 F& m$ W
: L3 o( r- [6 \/ ^# G6 \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! n, {2 b& ~1 A5 Z: Z
.leds = da850_evm_tl_leds,
# n& J1 ~ N! f0 E7 @- a* K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* T6 J6 _3 e1 _% r};4 I% a. e7 n0 L) d. [
# w* y j- g( w* ?7 h& p1 ^static void led_dev_release(struct device *dev)
u$ J5 l- U9 y9 L' d( U{
/ [5 C' U: E- c9 j3 Q" h$ c& L+ o0 |" ]};
# t9 N8 Y6 G, W+ ?2 P& h4 N$ l
3 o# i- ]$ B1 g8 c9 \4 S: K- Bstatic struct platform_device da850_evm_tl_leds_device = {
; C- D" N5 I& X& z& |* C6 s .name = "leds-gpio",& ~# I) }' ~' k3 i9 e
.id = 1,
e j; e/ F& @2 Z' J .dev = {9 M" L5 f; \/ i5 n. o$ W
.platform_data = &da850_evm_tl_leds_pdata, w# V) W8 O4 `
.release = led_dev_release,
0 c- I9 K% A7 d }
+ |! s# x1 k" f" ^. N};
9 [& X6 X3 V! s3 a: g+ ^; [9 B1 L# d2 k5 w) R: L3 W6 c$ j: i
static int __init led_platform_init(void)" M4 X* }+ r2 A7 L
{) b; ]# F) @# i8 S8 G7 S( b; ^* F5 L
int ret;
; P# W! S1 r0 S) E/ f#if 0
3 ?# e6 C$ L |4 q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( {. m0 Z2 M7 ]' }% o; Y
if (ret)) W! i+ a. u* F4 N% {$ C5 |9 I/ o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") o* W0 f1 O! z
"%d\n", ret);
8 S$ }1 z/ z5 d- _5 r! I9 t#endif
( z+ X6 B$ P2 ]% U9 s2 ~ ret = platform_device_register(&da850_evm_tl_leds_device);% v* m+ x b5 @& T3 k
if (ret)' b' L: z/ C e* K7 d
pr_warning("Could not register som GPIO expander LEDS");
6 b2 @ }* B1 l! [4 k else
. @: Z8 M" b" c) V- V printk(KERN_INFO "LED register sucessful!\n");
/ n& J0 f1 `, @2 |' W9 I! Y7 O9 S0 E; S0 @ u7 E
return ret;
3 K" U! l/ p; e3 b; g}1 ]9 F, x$ q1 N9 l* i' H
, A% ]& \- w3 w- Mstatic void __exit led_platform_exit(void)
( ^ S. c/ m* o$ A4 y9 D{
% Q6 ~+ T3 H8 N6 x& A platform_device_unregister(&da850_evm_tl_leds_device);
% g: C' M- ]2 ~1 P8 u' d/ j3 N
4 x' O1 M" O* @/ i8 q+ r printk(KERN_INFO "LED unregister!\n");
2 \" u' q6 k2 i}. y t# v0 A% p# }- M \
/ a/ c1 ?* C! i, U
module_init(led_platform_init);/ \8 E& V: L" a6 l" C+ c& N J) j" j
module_exit(led_platform_exit);
- }+ f+ s N+ ~
. Y( |' t M5 kMODULE_DESCRIPTION("Led platform driver");) o ?/ ?6 F n, x
MODULE_AUTHOR("Tronlong");
0 P4 C: s1 M$ Y) H% M8 PMODULE_LICENSE("GPL");
k& s S# b6 `/ h& A& M
: f4 M* k* _) @" E |
|