|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& O. C ~4 t1 `5 Y7 k4 c+ F
#include <linux/init.h>) u3 C6 `+ k/ c; ^. l4 T
#include <linux/module.h>
* f: g/ g; ~' U& [% M' a1 k#include <linux/kernel.h> N( f% @7 I9 X) C) A
#include <linux/types.h>
2 T$ J+ I$ z% |- f b#include <linux/gpio.h>6 i4 {9 D% |+ W& S; ^7 g
#include <linux/leds.h>
" J% p% [3 E8 V: i9 V+ ^2 t#include <linux/platform_device.h>
/ q+ j7 K' o2 [' X2 `9 {) |# `* ]
9 \+ \3 \, d& Q- H#include <asm/mach-types.h>; [* }) h0 D4 j! \5 w* j+ T
#include <asm/mach/arch.h>9 ?( a& C2 `8 o; }/ i1 P/ v
#include <mach/da8xx.h>2 o* g1 T8 `& ]
#include <mach/mux.h>( P* v: D: }, n c
8 W1 P9 ]6 z" |* q- ]2 V5 X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 M, a3 j7 r' l8 v7 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 v4 J o: p r8 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 ?7 V: q8 H1 d# E; X! \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
F3 ]3 o( e7 K* b% T
9 R" ^8 s8 B8 O' N8 i W3 Y, Z- q/* assign the tl som board LED-GPIOs*/
- u0 G f X8 istatic const short da850_evm_tl_user_led_pins[] = {
& E$ z/ y9 l+ t/ e% { o /* These pins are definition at <mach/mux.h> file */# U$ q! G9 j+ [0 m! a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& h- p# {4 @$ F+ T8 U C" R
-1
7 `) H$ x- E% D9 Y' y! w2 H ?};
. l9 Y" D# j* \; ]2 n ~4 e# `9 b. N" H" r" h
static struct gpio_led da850_evm_tl_leds[] = {& c1 P: q5 V/ r
{9 B0 n, {, `. ^
.active_low = 0,
' x2 P @( O6 H/ X6 Y .gpio = DA850_USER_LED0,6 e& O H+ U7 U( V6 _+ \+ i+ l' d
.name = "user_led0",, }' L. h" {) K3 S# Z/ ?
.default_trigger = "default-on",3 [0 x7 I0 _1 a) [% Q# D6 M: [1 f
},: A. O- x' n( f6 D
{' K0 d$ a( t6 K3 V5 L" N7 n4 F
.active_low = 0,% ?* r. h5 k' V. T+ t2 ?8 L6 y
.gpio = DA850_USER_LED1,0 `7 H' z& {4 V' r3 a
.name = "user_led1",+ C. y3 r- I: k4 |$ _8 r
.default_trigger = "default-on",1 o4 Z; g- c% ?' ^ Q
},
" r7 m |) Y* r. P) I5 P- Z {1 J, F! B! H9 H# h, C" a+ q* K" T
.active_low = 0,5 b! ~4 J. f/ g. a6 F6 ^
.gpio = DA850_USER_LED2,
* {/ b' X% k" L+ ~8 N .name = "user_led2",3 Z5 _1 H% x6 B. k5 w
.default_trigger = "default-on",
% c- }/ D- y5 L9 ~2 V, C5 B8 S! D5 q% F },1 E) z! _' {: P4 s! D4 R
{# T* o q2 e( t7 D
.active_low = 0,
; a/ o. z( g0 B2 l) r .gpio = DA850_USER_LED3,
" |: e. [8 H% H/ Z5 U" A9 e% a5 z( L .name = "user_led3",! c0 v, ?0 z! ~* {
.default_trigger = "default-on",
9 B B J" i# t. L% e7 } },# K4 \) d4 v& k! b) G( E3 L7 g" D
};: N4 i! o( c, {3 I+ U7 N
! i3 F" Y; A) `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) t% p9 ^$ |* ]$ U" e
.leds = da850_evm_tl_leds,
1 `2 y2 w9 \1 R/ W' c$ z/ n9 h+ y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 [$ a; _* S7 O9 G};
% W/ m8 m1 Q* m7 a" w+ r9 T
+ b A3 R2 y+ t1 q4 _3 `static void led_dev_release(struct device *dev)
) R- N# A. b! i. S# z# b{
) m7 ]9 {8 Q* S3 n6 y* o};
0 s9 s8 p) b( [* t) n9 S- D, \+ S& X* x1 x7 X! ?' U$ Y. }* i* y
static struct platform_device da850_evm_tl_leds_device = {6 ]" X, m! t t* p$ J
.name = "leds-gpio",
2 L1 Z# `0 y5 Q* y& N- f .id = 1,
5 r) C4 ~2 ^" Y" L- i' P0 l .dev = {$ m* B1 |4 T1 k# L4 ^, {
.platform_data = &da850_evm_tl_leds_pdata,
. ?. }3 R) r, Q8 A9 B .release = led_dev_release,
) h& f! f0 l9 P- V }
% S+ E8 m7 a' o: ?};. d* ~% M; s, O5 h1 i
$ u- \# \# Y' W* Sstatic int __init led_platform_init(void)0 t5 e0 \7 a' ]# z p: }0 h
{# m# W5 C$ A; q7 W
int ret;8 r$ y; }) G" d1 e) e
#if 0
% v" B# o( v- O& Q* o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. ~$ [) \' j; ?; x, V3 X4 \" [ if (ret)
, ]. m% o/ u) W- |. u, \# Z# ]- | pr_warning("da850_evm_tl_leds_init : User LED mux failed :" B) a) e8 X _" P8 Q( c* [
"%d\n", ret);
1 S, M+ G- _2 d h) ?$ t#endif R) u+ g) E+ X/ m
ret = platform_device_register(&da850_evm_tl_leds_device);! @# w) S; L% V- K, Q
if (ret)
$ i5 @+ Z+ p' Q0 c' \ x/ h pr_warning("Could not register som GPIO expander LEDS");
) |6 w! o! }. H6 t: p* q, \ else
" h0 H, Q: C: \. i2 | printk(KERN_INFO "LED register sucessful!\n");" o9 [% v- ]' b1 E* V* E" T
5 c( U# R3 K5 K9 J
return ret;
/ Z6 E k. }6 r6 x, Z}) W0 K7 \+ t/ Y% K) i
4 d: |! s% D: \! |5 \; H6 M: \static void __exit led_platform_exit(void)5 U- t/ o2 h9 q* P+ z4 N. @
{% w- w3 U3 ?/ H& M# C7 f
platform_device_unregister(&da850_evm_tl_leds_device);
! ^- y/ J& A& k% U( n8 u- V
. L. P. q+ p+ ^4 C) i printk(KERN_INFO "LED unregister!\n");* y& ]+ e% U0 _3 i Y
}5 `) q! n1 P5 j, d! Z
/ Y! d( S. m ^, \) t6 R5 g7 `module_init(led_platform_init);
. h( L0 s/ c+ g) ^' B7 t& F+ T7 omodule_exit(led_platform_exit);
% w" w" d2 {& t' g( {
$ h5 T8 Y/ H. P" \6 R/ _, C% FMODULE_DESCRIPTION("Led platform driver");6 w2 {4 u# x7 S5 s+ Y
MODULE_AUTHOR("Tronlong");- k5 }# d! z ^9 o
MODULE_LICENSE("GPL");" [8 E H4 K5 E6 ?& ]* K: Z2 y" ^
2 B8 w+ @' a Q$ V& w |
|