|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% x7 J, x$ K; G7 j2 @; r- H9 a, Z8 k
#include <linux/init.h>4 O) O0 L2 o/ A6 C1 r
#include <linux/module.h>
* F1 P4 U# I3 c5 u#include <linux/kernel.h>
# g# \; @9 Q, @: @5 A#include <linux/types.h>
8 i+ A7 g' K R1 ?% }#include <linux/gpio.h>
) U$ S* K) q! H7 Q" @! ?' Q#include <linux/leds.h>
/ x- J; Q4 d( `+ {9 S/ L& r! M+ f#include <linux/platform_device.h>4 l# Z( ], S) y1 @; ^1 \
% b/ w) R. g% F5 c: c5 L7 W; J, j: ?#include <asm/mach-types.h> h$ Q8 ^) V# h8 l5 u7 I
#include <asm/mach/arch.h>1 r O, n1 J5 V6 u; w5 M9 w! k8 n4 }2 \: R
#include <mach/da8xx.h>7 b& t: g6 V, m
#include <mach/mux.h>( v- r3 z: _# R% F
, Y n4 [6 f/ K5 P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) B6 i7 ]4 I# T: u, X/ Y, A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( _( h' u+ s1 D$ t1 l# B- m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). C9 @. n0 ^4 H) ~, h* J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 {! M% X& P" J. q! p
% }7 G O+ E# T( ~% e' u! i/* assign the tl som board LED-GPIOs*/
- w" s! v1 C; |; J% @* Nstatic const short da850_evm_tl_user_led_pins[] = {: O& @) L9 O" M! l$ f8 `
/* These pins are definition at <mach/mux.h> file */
# R8 w/ n" }: L5 M( n9 k3 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 u% m* n! v$ F4 H1 I3 V -1
' m; u7 `1 e) \7 F+ ]};
$ q. w) N+ \ H5 o0 F) X' ^4 P* v1 R# F/ B& a* Z" \# J
static struct gpio_led da850_evm_tl_leds[] = {
3 j. s$ E& {8 l7 G {, O1 e+ }8 R# A( d+ q; f' ]! n
.active_low = 0,
4 r2 `# i; a4 X' ]5 I1 m .gpio = DA850_USER_LED0,
6 Z/ H) ]- G" k. D5 J* ?$ F .name = "user_led0",. F/ y' b; U( m& p
.default_trigger = "default-on",
: a, W" X& C2 Q& P7 R$ L6 O },
- a# Z d: G8 G( r {
6 @ l- F1 Q/ g .active_low = 0,& f( u% V( S$ L
.gpio = DA850_USER_LED1,: { P7 |) O$ x# z1 `& ?
.name = "user_led1",
9 Y H- h1 }1 O$ Z8 j4 @$ D& Y& B .default_trigger = "default-on",* w" P0 }) R) {
},8 q5 w; W$ H5 H% p) P/ c4 m- K
{! ^* o: y$ L/ D0 O% S$ h0 L
.active_low = 0,; f. G. @9 y Q
.gpio = DA850_USER_LED2,
. w$ j$ c5 {! U: _ .name = "user_led2",
9 e$ N* F# g/ G8 s8 A* B# k .default_trigger = "default-on",# s% O" [7 e' h& [* H/ `
},% ]$ w$ `& D/ Q
{( y: [8 b3 B b* `6 n
.active_low = 0,
5 T# U7 Z5 r8 ?! A( u2 o* ` .gpio = DA850_USER_LED3,
/ A* p: }; F2 L( }, O. M% f1 ^ .name = "user_led3",
! R8 Q# i9 L) D+ f) c0 N .default_trigger = "default-on",
! c" S% |& E9 i, Z) r. h7 J },; T8 R$ ?; ?# ^* |5 K- K" F
};
, I, z7 N: i4 S) {. D: s8 G a+ O2 C, L$ `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; d$ r* ?3 d. H# R$ G
.leds = da850_evm_tl_leds,
( i/ c$ ^5 U( }& O3 n# T$ a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 y: X5 k2 U% E9 a! X0 z
};5 e' A' E& o* j- w1 C
8 w! H% z/ G+ ~
static void led_dev_release(struct device *dev)' U8 |' B- w: w. F6 ?
{' N" E) X" p7 R6 e" Q; G: \
};
! ]% ]( d. h' W( r9 r" j# A& Z5 c# t7 u& O9 u2 M* t* u" @/ m( c
static struct platform_device da850_evm_tl_leds_device = {
3 u. S: J j/ t5 R9 N .name = "leds-gpio",) R# @( K5 ^, u" }0 I
.id = 1,2 E! Q$ Z8 F2 Q4 w$ S
.dev = {
& ?# @* i: O8 k& y H .platform_data = &da850_evm_tl_leds_pdata,! Z. ?# T4 _9 F+ n. l; V Z7 Q
.release = led_dev_release,
& W" y; _7 t/ |8 D$ S }! d+ ]! R$ O: ^ y3 Y& {
};
) ]* i" e, | i6 q' I# w
! M5 W+ `1 T! _" T/ o0 Ostatic int __init led_platform_init(void)
& U; J. p5 ?5 t! v, K0 k{& X3 K1 ]: ^- ^" G
int ret;
- t7 Q* V1 B; |& U5 g# o- s7 p; W#if 0
3 L2 O/ E+ t5 H" k1 F* }& j1 Y* q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 v2 o( n9 t- E- c if (ret)
& d1 v, j- [- m6 u- B6 h9 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 ^: P! V. ]4 d# ?. V" X. H1 f "%d\n", ret);- a4 V0 q8 ~; s# K9 k
#endif
/ ^1 E: H) ], n5 O2 D; K/ Y: [' L) _/ o ret = platform_device_register(&da850_evm_tl_leds_device);5 w/ s7 S+ J1 N/ ~7 L
if (ret)
: G* q$ ~5 k% C; g1 ]7 M pr_warning("Could not register som GPIO expander LEDS");
+ q; U; g1 k6 J. H [7 l4 L; f else5 t* {, ^0 q6 K% W2 E1 ?) W' v
printk(KERN_INFO "LED register sucessful!\n");- d1 g0 U/ p$ a# d. Y$ H
! k2 U1 ?' Z3 J& }( O& Z
return ret;
6 c) C; ]# G0 Z& Q) p$ t' N7 g! z}" ]( z# ]6 j2 K
, i* e( Z8 O* N5 s; q, l x+ ^
static void __exit led_platform_exit(void), a% c4 _, A7 ~8 w& a
{
6 e1 ^! c+ ?, w5 T5 i( ?" c platform_device_unregister(&da850_evm_tl_leds_device);
& R8 e6 S. }3 J6 ?6 E0 W7 V: m3 i
printk(KERN_INFO "LED unregister!\n");
+ }# ~$ g8 l, J0 Z1 z7 C& L- o}. ^ y7 K- U2 ^9 z2 d) |- F% j
7 [* G( M! I; P% S* m Amodule_init(led_platform_init);( j- r5 s! E: W9 D' s. Z
module_exit(led_platform_exit);
: h7 @ J7 L1 E- |. C
9 e( R9 @! i; r0 \MODULE_DESCRIPTION("Led platform driver");
' H7 L( m _ G7 S3 O3 A# fMODULE_AUTHOR("Tronlong");+ |5 K- `# T# G7 l% G
MODULE_LICENSE("GPL");- A/ l* V+ e$ j
+ ~; h8 E& x0 x |
|